如何检测Windows被锁定? [英] How to detect Windows is locked?
问题描述
如何检测 Windows 是否被锁定(Win+L 或被屏幕保护程序锁定)?可能吗?
How to detect Windows is locked (Win+L or locked by screensaver)? Is it possible?
推荐答案
没有记录的方法来检查会话是否被锁定.然而,有一种方法可以检测会话是否被获取锁定.使用 WTSRegisterSessionNotification(),当工作站被锁定时,您将收到带有 WTS_SESSION_LOCK 值的 WM_WTSSESSION_CHANGE 消息.
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.
如果您打算从服务中执行此操作,请务必在 Google 上搜索会话 0 隔离"以找出不起作用的原因.
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.
这篇关于如何检测Windows被锁定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!