Home > Software engineering >  Capture the shutdown event, how to distinguish is shut down or restart?
Capture the shutdown event, how to distinguish is shut down or restart?

Time:09-21

Program function requirement is this: to capture to the shutdown event - & gt; Interrupt shutdown - & gt; Executable program finished backup database file - & gt; Continue to the shutdown event (shutdown mode unchanged)
Now use the WindowProc (UINT message, WPARAM WPARAM, LPARAM LPARAM) capture the shutdown event, seemed to distinguish not shutdown or restart, please expert advice, (it's better if can distinguish between dormancy and standby)

CodePudding user response:

If (m.M sg==WM_QUERYENDSESSION)

You need to check the lParam the value of the WM_QUERYENDSESSION message.

As the documentation are:

If the parameter is zero, the system is shutting down or restarting (it is not possible to determine which event is occurring).

If the parameter is ENDSESSION_CLOSEAPP x00000001 (0), the application is using a file that must be replaced, the system is being serviced, or the system resources are exhausted.

If the parameter is ENDSESSION_CRITICAL (0 x40000000), the application is forced to shut down.

If the parameter is ENDSESSION_LOGOFF (0 x80000000), then the user is logging off.

CodePudding user response:

LParam value, shutdown, restart didn't distinguish, are all zero

CodePudding user response:

Can I encountered similar problems, by capturing message but shutdown and restart the value is 0, the original poster to find a way, I also try to read the log, but because the log write shutdown or restart event time is at the end of the program to run, so always can't go to the shutdown and restart the difference between events
  • Related