473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 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 3186
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Porky | last post by:
Scenario: login/logoff scripts that kick username, times, and dates out to a CSV file. I have a linked table in access pointing to that CSV file. Users typically log in and log out twice a day...
1
by: MCzajk | last post by:
Is there a way to intercept event, when user logs on/off to the system inside windows service? Thx for any tip, MCzajk
7
by: Aarti | last post by:
I have written a windows service that needs to perform certain functions only if a User is logged in. The problem I am running into is that I get an error if the computer is in the process of being...
2
by: NWx | last post by:
Hi, I have the following question: I have an app that uses user login/logout to identify users When user logon, I register logon time in a session variable When user logoff using the logout...
6
by: Randall Parker | last post by:
Suppose the first URL a visitor visits is Logon.aspx. There's not an original page to return the user to. So how can I detect whether to send the user to the original page he tried to visit versus...
5
by: Paal Berggreen | last post by:
I am involved with development of a Portal solution using ASP.NET 2.0 and WebParts. The WebParts framework use the default personalization providers, and the personalization data thus ends up in...
0
by: gewe | last post by:
Can anyone tell me what is wrong with the following code? The code has to watch for logon/logoff events: public void StartListenLogon() { EventHandler handler = new EventHandler();...
2
by: =?Utf-8?B?SVNE?= | last post by:
Question: How do I refresh on the local computer the users AD( LDAP ) credentials without having them re-log our re-boot their system? Scenario: Users A is denied access to folder Z. Admin on...
2
by: Dan2kx | last post by:
Function LogonLog(OnOff As String) Dim rst As DAO.Recordset If OnOff = "On" Then Set rst = CurrentDb.OpenRecordset("tblLogonLog", dbOpenDynaset, dbAppendOnly) rst.AddNew ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.