Click to See Complete Forum and Search --> : Mainting Cursor Control / Detecting Winlogon


leojose
June 8th, 2005, 05:56 AM
Hi all,

My application required me to monitor the mouse events and then either hide it or show during certain events. I have managed to succesfully do this using the SetWindowsHookEx() to capture the LowLevelMouseProc().
But now I face a new problem. When somebody locks the workstation, my program is unable to monitor the mouse events and take appropriate action(like hiding or showing the cursor).
Basically what i need to do is to get an indication whether the OS workstation has been locked and depending on that i will put the cursor in a visible condition.
I need to know how I can find the login state of the PC?

Regards

golanshahar
June 8th, 2005, 08:09 AM
i think you should get the WM_ENDSESSION i am not sure though one thing for sure you can check it by using the next code


bool IsWindowsLogon ( )
{
HDESK hDesktop = ::OpenInputDesktop (0, 0, 0);

if ( !hDesktop )
return true;

DWORD dw = 0;
char szName[MAX_PATH];
::memset(szName,0,sizeof(szName));

if ( !::GetUserObjectInformation(hDesktop, UOI_NAME,&szName, sizeof(szName), &dw) )
{
::CloseDesktop(hDesktop);
return false;
}

::CloseDesktop(hDesktop);

if ( ::strcmpi(("Winlogon"), szName) == 0 )
return true;

return false;

}

it should work but you need to check it in timer all the time :-( or in the mouse hook message u can add it in order to save creation of another timer.

if someone know another solution i would like to know.

Cheers