How to detect Windows is locked (Win+L or locked by screensaver)? Is it possible?
Press CTRL+ALT+DELETE to unlock the computer. Type the logon information for the last logged on user, and then click OK. When the Unlock Computer dialog box disappears, press CTRL+ALT+DELETE and log on normally.
Yes, when the computer is in lock mode the program and you run any programs it will run, if it is in sleep mode, program will stop running.
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.
WTSRegisterSessionNotification() will require the elevated privileges on Windows 10/11.
Call WTSQuerySessionInformation with WTS_INFO_CLASS set to WTSSessionInfoEx.
struct _WTSINFOEX_LEVEL1_A has a member, LONG SessionFlags, which indicates whether the calling session is locked or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With