471,598 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,598 software developers and data experts.

Catching events when users logon/logoff

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
Dec 1 '05 #1
2 3105
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
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Raimund Taschler" wrote:
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

Dec 1 '05 #2
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]

"Raimund Taschler" <ta*@adv.magwien.gv.at> wrote in message
news:11**************@proxy.dienste.wien.at...
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

Dec 1 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Aarti | last post: by
2 posts views Thread by NWx | last post: by
6 posts views Thread by Randall Parker | last post: by
5 posts views Thread by Paal Berggreen | last post: by
reply views Thread by gewe | last post: by
2 posts views Thread by =?Utf-8?B?SVNE?= | last post: by
2 posts views Thread by XIAOLAOHU | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.