How to shutdown my app gracefully at CMainFrame Initialization
-
Maybe it sounds stupid, but how can i shutdown my app gracefully at CMainFrame Initialization ? I just want to do some system checks and if they fail, then immediately terminate the app before any window is created. Any known methods like PostQuitMessage(0), PostMessage or OnClose etc fails because mainframe window is not created yet. Where to use exit code ? PS: I dont want to use the InitInstance from my App. Regards,
sdancer75
-
Maybe it sounds stupid, but how can i shutdown my app gracefully at CMainFrame Initialization ? I just want to do some system checks and if they fail, then immediately terminate the app before any window is created. Any known methods like PostQuitMessage(0), PostMessage or OnClose etc fails because mainframe window is not created yet. Where to use exit code ? PS: I dont want to use the InitInstance from my App. Regards,
sdancer75
PostQuitMessage
definitely works when called from the constructor ofCMainFrame
. You can check the exit code using the functionGetExitCodeProcess
. This can be used when invoking the application using theCreateProcess
API, where it first waits for the program to terminate using theWaitForSingleObject
function. Otherwise you can get the exit code by checking theERRORLEVEL
variable when run from the command prompt or a batch file. Here is more information on this - ERRORLEVEL is not %ERRORLEVEL%[^]«_Superman_» _I love work. It gives me something to do between weekends.
_Microsoft MVP (Visual C++) (October 2009 - September 2013)
-
PostQuitMessage
definitely works when called from the constructor ofCMainFrame
. You can check the exit code using the functionGetExitCodeProcess
. This can be used when invoking the application using theCreateProcess
API, where it first waits for the program to terminate using theWaitForSingleObject
function. Otherwise you can get the exit code by checking theERRORLEVEL
variable when run from the command prompt or a batch file. Here is more information on this - ERRORLEVEL is not %ERRORLEVEL%[^]«_Superman_» _I love work. It gives me something to do between weekends.
_Microsoft MVP (Visual C++) (October 2009 - September 2013)