WM_ENDSESSION: See if its a restart or shutdown

  • Thread starter Thread starter Thomas Johansen
  • Start date Start date
T

Thomas Johansen

Hi

I need my Windows Service to know when the system is shutting down. But it
has allso to know if its a reboot or a shutdown !!!

Is there any way of see this ?? I could use the WM_ENDSESSION and then see
if its a restart or shutdown

I need to tell some eksternal equipment, connect on the COM port, that the
PC is shutting down of restarted !!!
Thomas
 
Hello

I don't know if a windows service gets windows broadcast messages
but a standard windows app can process the WM_QUERYENDSESSION
message and stop the shutdown process if necessary

Hope this helps
 
I don't know if a windows service gets windows broadcast messages
but a standard windows app can process the WM_QUERYENDSESSION
message and stop the shutdown process if necessary

Yes.. But can it see the difference between af shutdown and a restart ?
 
Thomas Johansen said:
Yes.. But can it see the difference between af shutdown and a restart ?


I could'nt find any info on that. If unable to determine if shutdown or
restart
was used, a workaround may be to intercept the WM_QUERYENDSESSION
message, return 0, then ask the user again if its a shutdown or restart.
and use ExitWindowsEx accordingly.
 
I'm curious how you are going to use this information. Just because the
machine is being restarted doesn't mean your service will run again. It
could be running a different operating system or a last known good config.

Seems like all you can do is treat the events the same and shut down the
external equipment.
 
Back
Top