vb.netservicesystemevent

System events with vb.net service


I try to create windows service to write events win windows sessionswitch event, but when I make it in windows application it work fine but doesn't work with service. After search I know the system events need message loop enabled so how I can enable it in vb.net windows service


Solution

  • In order to receive Windows Messages, your program must have a window. As noted on the SessionSwitch MSDN page:

    In a Windows service, unless a hidden form is used or the message pump has been started manually, this event will not be raised.

    A link is included which gives an example showing how to receive these events with a hidden window. Message Only Windows are another, similar option for receiving window events and messages.