I am trying to create a service which tracks the desktop events like LOCK, LOGOFF, SHUTDOWN etc,
I need to write the time (and date) in a text file,
regards.
I am trying to create a service which tracks the desktop events like LOCK, LOGOFF, SHUTDOWN etc,
I need to write the time (and date) in a text file,
regards.
you should be able to get the information you are looking for from Microsoft.Win32.SystemEvents.
The SessionSwitch event will tell you when the user is switched or the computer is locked. http://msdn.microsoft.com/en-us/library/microsoft.win32.sessionswitcheventargs(v=VS.90).aspx
How can I programmatically determine if my workstation is locked has a lot of information on this.
Implement the service's OnStart, OnShutdown and OnSessionChange methods. Not so sure that OnSessionChange still works on Vista and Win7, services run in an isolated session called Session 0. I seriously doubt it, no workaround for it.