How to handle Windows shut down from code?
Posted on 2008-10-23
My MFC application needs to perform some quick cleanup code before shutting down. (Log a couple of info to the Event log and close some files).
So I have put my shutdown code in the ExitInstance() of the main class.
The user would typically stop the application by pressing the power button on the Server. I thought this was sending a WM_QUIT message to all application, which in turn should be handled by the ExitInstance(), but ExitInstance() never gets called if the app is shutdown this way.
So how is my application suppose to handle getting killed on a Windows shutdown?