Is it possible to catch SystemEvent in Windows service?
-
Hi. Is it possible to catch system events such as SessionEnding in a windows service? I tried to hook on a method to the event, like Microsoft.Win32.SystemEvents.SessionEnding +=new Microsoft.Win32.SessionEndingEventHandler(this.OnSessionEnding); in the OnStart() method but now the service won't start. Is the problem that the service can not catch systemevents at all or have I done something wrong? Thanks /EnkelIk
-
Hi. Is it possible to catch system events such as SessionEnding in a windows service? I tried to hook on a method to the event, like Microsoft.Win32.SystemEvents.SessionEnding +=new Microsoft.Win32.SessionEndingEventHandler(this.OnSessionEnding); in the OnStart() method but now the service won't start. Is the problem that the service can not catch systemevents at all or have I done something wrong? Thanks /EnkelIk
hi I guess you need to write an event handler function and event handler delegate. see if the following link can be of any help: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfmicrosoftwin32sessionendedeventhandlerclasstopic.asp http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconeventsdelegates.asp all the best. ankita