Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to shutdown my app gracefully at CMainFrame Initialization

How to shutdown my app gracefully at CMainFrame Initialization

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sdancer75
    wrote on last edited by
    #1

    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

    _ 1 Reply Last reply
    0
    • S 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

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      PostQuitMessage definitely works when called from the constructor of CMainFrame. You can check the exit code using the function GetExitCodeProcess. This can be used when invoking the application using the CreateProcess API, where it first waits for the program to terminate using the WaitForSingleObject function. Otherwise you can get the exit code by checking the ERRORLEVEL 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)

      Polymorphism in C

      S 1 Reply Last reply
      0
      • _ _Superman_

        PostQuitMessage definitely works when called from the constructor of CMainFrame. You can check the exit code using the function GetExitCodeProcess. This can be used when invoking the application using the CreateProcess API, where it first waits for the program to terminate using the WaitForSingleObject function. Otherwise you can get the exit code by checking the ERRORLEVEL 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)

        Polymorphism in C

        S Offline
        S Offline
        sdancer75
        wrote on last edited by
        #3

        Thanks for the reply. Yes indeed it works but since i am using codejock's library i get assertion errors and the app is not closing as it would expected but it stays alive doing nothing (no mouse or keyboard response). Regards,

        sdancer75

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups