My application throws some strange errors if you shut down the computer while my application is running.
Sometimes the message is (address) memory can not be "read", sometimes can not be "write".
Shutting down the application in the normal way doesn't generate such messages.
How can I simulate the "windows shutdown" so that I can debug my application? How can I find out what the application is trying to do that it cannot?
When Windows wants to shutdown, it sends a series of events to the application; such as WM_ENDSESSION
and WM_QUIT
. You can process these in the message handler you are using; in general the application will need to respond appropriately and quickly to these messages else the OS will just terminate the application anyway. I'm not sure what default processing wxwidgets offers in this regard. Hooking into these would help in diagnosing the application error itself.
There are a few things you could attempt to do;
WM_QUERYENDSESSION
and respond with a FALSE
to prevent it from shutting down (with newer versions of Windows you can no longer prevent the shutdown, so it may not work depending on the platform you are on).WM_ENDSESSION
message by sending it the WM_ENDSESSION
(e.g. via a PostMessage
) with the appropriate data as detailed on MSDN.For terminal based applications;
You can also hook in the signals (SIGKILL
I believe) if required. See this Microsoft reference for more detail. You can also the the SetConsoleCtrlHandler
hook. But since you using a toolkit, it would be better to use the messages sent to the application already.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With