Reputation: 11
I have written an Windows service which should record any system shutdowns. The WINAPI provides the SERVICE_CONTROL_PRESHUTDOWN (Vista and higher), and SERVICE_CONTROL_SHUTDOWN. But neither of them is triggered in my service control handler, which was registered before to RegisterServiceCtrlHandlerEx(). In particular, nothing is passed to it when the system is rebooted. The handler itself works, since SERVICE_CONTROL_STOP etc. is triggered correctly.
Is there any other way to keep track of system shutdowns instead of using the Service Control Handler?
Upvotes: 0
Views: 315
Reputation: 91320
You need to call SetServiceStatus passing SERVICE_ACCEPT_SHUTDOWN/SERVICE_ACCEPT_PRESHUTDOWN in order to receive the shutdown controls.
Upvotes: 2