This is in regards to applications that run in the taskbar but should be applicable to standard apps, Winforms, WPF, etc.
Question: I am after some method (preferably via managed code) to be notified when a user either has their screen "locked" while my app is running and/or know when they log back in.
GMail Notifier does this sort of thing for e开发者_如何学Pythonxample, if my PC is locked for a while when I log in again it shows a list of emails that arrived since locking the PC. I'm looking to replicate that kind of functionality.
Does anyone have any ideas on how to accomplish this?
You want to hook into the System Event Notification Service and subscribe to the ISensLogon DisplayLock/DisplayUnlock events.
The question mentioned by Mike Daniels has answers:
Checking for workstation lock/unlock change with c#
The one I prefer is using is SessionSwitchReason
:
http://msdn.microsoft.com/en-us/library/microsoft.win32.sessionswitchreason.aspx
精彩评论