I have been writting a DLL, and tried to get notification about locking the screen by user. I found that WM_WTSSESSION_CHANGE will be suitable for my needs, but I cannot read this message in my library,
moreover when I have spied the app with the spyxx.exe
I could see that the WM_WTSSESSION_CHANGE
message is posted.
Could anyone take a look and say what am I doing wrong?
Some essentials listings:
setting up WndProc callback:
HHOOK hook = SetWindowsHookEx(
WH_CALLWNDPROC,
(HOOKPROC) __monitor,
hInstance,
GetCurrentThreadId());
registry for event notification:
WTSRegisterSessionNotification(hwnd, NOTIFY_FOR_THIS_SESSION);
a callback function:
LRESULT CALLBACK __monitor(
int code,
WPARAM wParam,
LPARAM lParam)
{
CWPSTRUCT *msg= (CWPSTRUCT *) lParam;
// have verified that the statement : hwnd == msg->hwnd is true
switch (msg->message)
{
// ...
case WM_DESTROY:
//... this case is handled OK
break;
case WM_WTSSESSION_CHANGE:
//... FAIL, never enters here
break;
}
// CallNextHookEx ..
}