Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Service HandlerEx: SERVICE_CONTROL_SESSIONCHANGE

970 views
Skip to first unread message

Andreas Schwarz

unread,
Dec 11, 2003, 4:52:03 AM12/11/03
to
Hello,

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

Remy Lebeau (TeamB)

unread,
Dec 11, 2003, 1:58:26 PM12/11/03
to

"Andreas Schwarz" <andreas...@hamburg.de> wrote in message
news:3fd8...@newsgroups.borland.com...

> 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


0 new messages