我以前没有找到这个,但是从任何应用程序中,您都可以连接SessionSwitchEventHandler。显然,您的应用程序将需要运行,但前提是:
Microsoft.Win32.SystemEvents.SessionSwitch += new Microsoft.Win32.SessionSwitchEventHandler(SystemEvents_SessionSwitch);void SystemEvents_SessionSwitch(object sender, Microsoft.Win32.SessionSwitchEventArgs e){ if (e.Reason == SessionSwitchReason.SessionLock) { //I left my desk } else if (e.Reason == SessionSwitchReason.SessionUnlock) { //I returned to my desk }}


