Possible Duplicate:
How can I programmatically determine if my workstation is locked?
What is the best way to determine if the desktop is locked for the currently logged in user? I looked in MSDN and couldn't find any API calls to detect this. Did I miss something, or is there no simple call I can use?
Locking the computer means your apps are still ON and running. Logging/signing off will CLOSE all applications before signing out of the session. Disconnect Session (Switch User) also keeps your apps running. Lock Workstation: This option will lock the computer but keep all the user's programs running.
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.
Desktop Lock is a computer security protection and access control software product. You can use it to lock computer to prevent people from accessing your private documents and resources. When the computer is locked by Desktop Lock, none can access your documents, browse your computer, or use programs on your computer.
The answer depends on whether you want to know if the desktop is locked now, or if you want to be notified when the desktop gets locked (and, presumably, unlocked). It also depends on how you're planning to receive said notifications.
If you really want a one-off test, then the answer here uses OpenDesktop()
and SwitchDesktop()
to open a handle to the default desktop and activate it - if this fails then it's a good sign that the desktop is locked right now.
If you want notification on lock/unlock, and you have a user-mode application with a window and a message pump, then you need to call WTSRegisterSessionNotification()
and catch the WM_WTSSESSION_CHANGE
message.
If you want notifications, and you're running as a Windows service, then you can register for session change events by calling SetServiceStatus()
and adding SERVICE_ACCEPT_SESSIONCHANGE
to dwControlsAccepted
in your status structure. You will then receive callbacks to your own service control HandlerEx()
function with dwControl
set to SERVICE_CONTROL_SESSIONCHANGE
.
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