Catching events when users logon/logoff

  • Thread starter Raimund Taschler
  • 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
 
G

Guest

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
 
S

Stoitcho Goutsev \(100\) [C# MVP]

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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top