.net - 知道 Windows 用户是否处于事件状态

标签 .net windows

在 Windows 中,我可以在不注销的情况下登录和切换用户。就像那样,我可以让多个用户登录,但只有一个用户在工作。我怎么知道哪个用户当前正在工作。

最佳答案

实际上我在 c# 中找到了一个很好的 Microsoft 示例 ( Detect the Windows session state )。

他们注册到系统事件“SessionSwitch”

SystemEvents.SessionSwitch += new SessionSwitchEventHandler(SystemEvents_SessionSwitch);

void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e){
...
}

它需要 Win32 的依赖

using Microsoft.Win32;

我试过了,它工作得很好而且相对容易。

关于.net - 知道 Windows 用户是否处于事件状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14730092/

相关文章:

.net - Threading.Tasks.TaskScheduler - 请帮我解决这个问题

c# - 为什么 WinForms 应用程序默认是 STAThread?

c# - 如何对列表进行排序,既不是升序也不是降序,而是自定义

windows - 如何从交互式 session 启动非交互式进程

windows - 运行 SML 文件但不处于交互模式

python - 如何在 Windows 上从 python 获取长文件系统路径

c# - 在 C# 中播放声音 - 使用所有方法中的哪一种?

c# - Visual Studio 2012 中的纯 C# 编辑器(无智能感知、无缩进、无代码突出显示)

windows - 无法在 Windows XP 上使用 npm 安装 CoffeeScript

c++ - VS 2010 构建错误