开发者

How to know when a user console is locked or has logged "back into" windows

开发者 https://www.devze.com 2022-12-29 23:44 出处:网络
This is in regards to applications that run in the taskbar but should be applicable to standard apps, Winforms, WPF, etc.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消