C#如何获得计算机的登录、注销、锁定等状态
2016-06-17 10:23
330 查看
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
SystemEvents.SessionSwitch += new SessionSwitchEventHandler(SystemEvents_SessionSwitch);
}
~Form1()
{
//Do this during application close to avoid handle leak
Microsoft.Win32.SystemEvents.SessionSwitch -= new SessionSwitchEventHandler(SystemEvents_SessionSwitch);
}
void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
{
switch (e.Reason)
{
case SessionSwitchReason.SessionLogon:
case SessionSwitchReason.SessionUnlock:
MessageBox.Show("没有锁住");
break;
case SessionSwitchReason.SessionLock:
MessageBox.Show("锁住");
break;
case SessionSwitchReason.SessionLogoff:
break;
}
}
}
{
public Form1()
{
InitializeComponent();
SystemEvents.SessionSwitch += new SessionSwitchEventHandler(SystemEvents_SessionSwitch);
}
~Form1()
{
//Do this during application close to avoid handle leak
Microsoft.Win32.SystemEvents.SessionSwitch -= new SessionSwitchEventHandler(SystemEvents_SessionSwitch);
}
void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
{
switch (e.Reason)
{
case SessionSwitchReason.SessionLogon:
case SessionSwitchReason.SessionUnlock:
MessageBox.Show("没有锁住");
break;
case SessionSwitchReason.SessionLock:
MessageBox.Show("锁住");
break;
case SessionSwitchReason.SessionLogoff:
break;
}
}
}
相关文章推荐
- 数据结构之循环队列
- URL的介绍使用和URLConnection的使用
- 模拟登录
- nginx配置详解之http模块
- Caffe小玩意(1)-可视化网络结构
- 网络信息安全学习平台--注入关第5题
- 【IOS网络编程】socket编程 - Asyncsocket
- 关于HTTP
- 学习TensorFlow,保存学习到的网络结构参数并调用
- 学习TensorFlow,保存学习到的网络结构参数并调用
- OKhttp的封装工具类(可以直接使用)
- IPC网络高清摄像机基础知识6(CCD 与 CMOS传感器)
- 通过HttpServletRequest获取服务器路径
- HttpPost和HttpGet解析
- 计算机网络归纳
- HTTP客户端代码片段
- 算法导论之数据结构
- Android 的一个简单的Http下载文件的方法
- 从数学的视角看社交网络
- Android开发框架xUtils3.x新手教学(二)HTTPS访问