I call RegisterEventSource() function during my service stop. But it is returning null during system shutdown. Is there any reason for this behavior?
Error: I get error code 0x800706b5 on GetLastError()
When googled, I came to know that it has something to do with missing registry data.
Also, how to check if system shutdown has started? (i.e equivalent to HasShutdownStarted() in C#)
Services can specify whether they will be notified when the system shuts down. Call SetServiceStatus() with
SERVICE_ACCEPT_SHUTDOWNflag. You will then receive theSERVICE_CONTROL_SHUTDOWNmessage in your service control message handler.EDIT: If indeed, as Zach suggests, the problem you are having with RegisterEventSource is because the event service has already shut down, doing your event log writes in response to this notification may fix that problem as well.