当前位置:网站首页>C# 无操作则退出登陆
C# 无操作则退出登陆
2022-07-24 15:08:00 【ITKEY_】
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace LockScreenMsg
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
label1.Height = 200;
}
[StructLayout(LayoutKind.Sequential)]
struct LASTINPUTINFO
{
[MarshalAs(UnmanagedType.U4)]
public int cbSize;
[MarshalAs(UnmanagedType.U4)]
public uint dwTime;
}
[DllImport("user32.dll")]
static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
static long GetLastInputTime()
{
LASTINPUTINFO vLastInputInfo = new LASTINPUTINFO();
vLastInputInfo.cbSize = Marshal.SizeOf(vLastInputInfo);
if (!GetLastInputInfo(ref vLastInputInfo))
{
return 0;
}
return Environment.TickCount - (long)vLastInputInfo.dwTime;
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = true;
}
public string isNull = null;
private void timer1_Tick(object sender, EventArgs e)
{
long time=GetLastInputTime()/1000;
this.label1.Text = string.Format("用户已经{0}秒没有操作了", time);
if (time >= 20)
{
this.Close();
}
}
}
}
参考
边栏推荐
- spark学习笔记(三)——sparkcore基础知识
- Under multi data source configuration, solve org.apache.ibatis.binding Bindingexception: invalid bound statement (not found) problem
- LeetCode·每日一题·1184.公交站间的距离·模拟
- Outlook tutorial, how to set rules in outlook?
- Unity uses NVIDIA flex for unity plug-in to realize the effects of making software, water, fluid, cloth, etc. learning tutorial
- LeetCode高频题56. 合并区间,将重叠的区间合并为一个区间,包含所有区间
- (09) flask is OK if it has hands - cookies and sessions
- Grpc middleware implements grpc call retry
- Research Summary / programming FAQs
- AG. DS binary tree -- hierarchical traversal
猜你喜欢

Use of keywords const, volatile and pointer; Assembly language and view of register status

深入浅出边缘云 | 2. 架构

Route planning method for UAV in unknown environment based on improved SAS algorithm

Discussion and legitimacy of the order of entering and leaving the stack

Under multi data source configuration, solve org.apache.ibatis.binding Bindingexception: invalid bound statement (not found) problem

25.从生磁盘到文件

文件操作详解

Problem handling of repeated restart during Siemens botu installation
DS binary tree - parent and child nodes of binary tree

LeetCode高频题56. 合并区间,将重叠的区间合并为一个区间,包含所有区间
随机推荐
REST风格
Here comes the problem! Unplug the network cable for a few seconds and plug it back in. Does the original TCP connection still exist?
Kali concise language transformation method (illustration)
Rasa 3.x learning series -rasa [3.2.4] - 2022-07-21 new release
Existence form and legitimacy of real data in C language (floating point number)
Can't remember regular expressions? Here I have sorted out 99 common rules
Discussion and legitimacy of the order of entering and leaving the stack
Deep learning 1 perceptron and implementation of simple back propagation network
Google Earth Engine——使用MODIS数据进行逐月数据的过火(火灾)面积并导出
Can you buy 6% of financial products after opening a stock account?
佣金哪家券商最低,我要开户,手机上开户安不安全
The server switches between different CONDA environments and views various user processes
PrestoUserError: PrestoUserError(type=USER_ERROR, name=INVALID_FUNCTION_ARGUMENT, message=“Escape st
Problem handling of repeated restart during Siemens botu installation
《Route planning method for UAV in unknown environment based on improved SAS algorithm》翻译
Vector introduction and underlying principle
Time series of machine learning
Various searches (⊙▽⊙) consolidate the chapter of promotion
Unity 使用NVIDIA FleX for Unity插件实现制作软体、水流流体、布料等效果学习教程
25.从生磁盘到文件