I have a little problem:
I'm running a service which has initialized a HandlerEx Callback function
and i'm waiting for
the event SERVICE_CONTROL_SESSIONCHANGE to get notify when the user is
changing or whatever happen
to the user.
Now i have the SessionID (Example: User1=0 User2=1 ...)
case SERVICE_CONTROL_SESSIONCHANGE:
sessionid = ((PWTSSESSION_NOTIFICATION)lpEventData)->dwSessionId;
Next i want to get the username... how to do this ?
I know that this is only working on Windows XP > Systems, but how do i got
notified when the user
is changed on Windows 2000 ?
Greetings,
Andreas
> Next i want to get the username... how to do this ?
Use WTSQuerySessionInformation() with the WTSInfoClass parameter set to
WTSUserName.
> I know that this is only working on Windows XP Systems
Correct
> but how do i got notified when the user
> is changed on Windows 2000 ?
You don't, not via HandlerEx() anyway. That capability was added in XP.
You will just have to use a separate window that intercepts the
WM_QUERYENDSESSION and WM_ENDSESSION messages to see when the user is
logging out. But you can't detect when the user is logging in that way. You
would probably have to write a replacement GINA.DLL to hook into the
WinLogon screen itself.
Otherwise, the simpliest way to detect login and logout is to simply run a
loop that repeadedly gets the username of the currently active user, and
then check when that value changes.
Gambit