How to detect Windows is locked?

前端 未结 1 920
孤城傲影
孤城傲影 2021-01-12 15:08

How to detect Windows is locked (Win+L or locked by screensaver)? Is it possible?

1条回答
  •  孤城傲影
    2021-01-12 15:28

    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.

    0 讨论(0)
提交回复
热议问题