Catching events when users logon/logoff

  • Thread starter Thread starter Raimund Taschler
  • Start date Start date
R

Raimund Taschler

Hi all,

I'm implementing a windows service (running with local system account) which
has to do some tasks when users logon/logoff. How can the service register
to those logon/logoff-events? I'm using .NET 1.1 and C# and the service will
be installed on machines with os >= W2K.

If you have any solution or hint tracking down this problem please let me
know!

Regards
Raimund
 
WMI (in System.Management namespace) offers a large number of various event
providers for this type of requirement. Hint: not for the faint of heart,
will require some study.
Good Luck!
Peter
 
Hi
In order to receive such notifications you need to register windows handler
(HWND) with WTSRegisterSessionNotification (see MSDN for more info)

Unfortunately there is no managed solution for this and you neet to use
PInvoke.

Services don't provide UI, but you can create a hidden form that will
receive the notfication. I believe this won't be a security issue as long as
you don't show it.


HTH
Stoitcho Goutsev (100) [C# MVP]
 
Back
Top