I'm working with old-school windows programming in C++, and I need to capture an event in my WndProc which indicates that the user has logged off or locked the screen.
update (thanks David Hefernan) I've searched everywhere, but the only thing I've found is the WM_ENDSESSION message - which does not handle screen lock events.
Anyone know what how this is done? I need to apply it to Windows 2000 through Windows XP flavors.
The solution is to register for the WM_WTSSESSION_CHANGE
and respond to it in your WndProc.
According to the documentation of WM_WTSSESSION_CHANGE
, the minimum supported OS is XP. Now, the since Windows 2000 is no longer supported, the documentation often says XP is the minumum when in fact the functionality is available on earlier versions. In this case, a quick web search suggests that you may be disappointed.
To be notified about session logoff (rather then the screen lock), you should be able to use the lParam
value of the WM_ENDSESSION
message. Look for the presence of the ENDSESSION_LOGOFF
flag.
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