我正在开发一个应用程序以在后台运行以捕获用户在其系统上的活动,例如注销/关机/空闲/切换用户/继续按下任何键/系统锁定等。
它工作正常,我能够跟踪所有活动,现在我需要在系统锁定 15 分钟后自动注销用户。
我已经尝试了下面的代码。该ExitWindowsEx()
功能在用户登录时工作正常,但在用户锁定系统后无法正常工作。
使用代码
[DllImport("user32")]
public static extern bool ExitWindowsEx(uint uFlags, uint dwReason);
private SessionSwitchEventHandler sseh;
void SysEventsCheck(object sender, SessionSwitchEventArgs e)
{
switch (e.Reason)
{
case SessionSwitchReason.SessionLock:
if(condition)
{
ExitWindowsEx(0, 0);
}
break;
}
}
任何人都可以帮助我在用户处于锁定状态时如何注销用户。