WM_ENDSESSION: See if its a restart or shutdown

  • Thread starter Thomas Johansen
  • 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
 
W

WRH

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
 
T

Thomas Johansen

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 ?
 
W

WRH

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.
 
K

Ken Wickes [MSFT]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top