How to detect Windows is locked (Win+L or locked by screensaver)? Is it possible?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
There is no documented way to check if the session is locked. There is however a way to detect that the session is getting locked. Use WTSRegisterSessionNotification(), you'll get a WM_WTSSESSION_CHANGE message with the WTS_SESSION_LOCK value when the workstation is being locked.
If you are planning to do this from a service then be sure to google "session 0 isolation" to find out why that doesn't work.