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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Exit Code (0x2) from Dialog Based Apps

Exit Code (0x2) from Dialog Based Apps

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingc++visual-studiohelpquestion
6 Posts 3 Posters 2 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.
  • J Offline
    J Offline
    Justin Cooke
    wrote on last edited by
    #1

    Greetings, I have been using dialog based MFC apps for a while and just noticed that, at least in my applications, the exit codes aren't always 0 (even when things seem to be working correctly otherwise.) If I run any of my dialog apps from the debugger in VS 6.0, and I then close the app with either System->Close, Alt-F4, or the 'X', I see the following messages: The thread 0xBF4 has exited with code 2 (0x2). The program 'C:\Documents and Settings\justin.cooke\My Documents\MyProjects\randomNumGen\Debug\randomNumGen.exe' has exited with code 2 (0x2). If I instead close it with the OK or Cancel buttons, the exit codes are 0, as expected. What's going on? Does the 2 code just indicate how the app was closed? I was always under the impression that a code other than 0 indicated an error. I tried to find a list of what these codes mean in MSDN and online, but had no luck. Thanks, Justin

    D M 2 Replies Last reply
    0
    • J Justin Cooke

      Greetings, I have been using dialog based MFC apps for a while and just noticed that, at least in my applications, the exit codes aren't always 0 (even when things seem to be working correctly otherwise.) If I run any of my dialog apps from the debugger in VS 6.0, and I then close the app with either System->Close, Alt-F4, or the 'X', I see the following messages: The thread 0xBF4 has exited with code 2 (0x2). The program 'C:\Documents and Settings\justin.cooke\My Documents\MyProjects\randomNumGen\Debug\randomNumGen.exe' has exited with code 2 (0x2). If I instead close it with the OK or Cancel buttons, the exit codes are 0, as expected. What's going on? Does the 2 code just indicate how the app was closed? I was always under the impression that a code other than 0 indicated an error. I tried to find a list of what these codes mean in MSDN and online, but had no luck. Thanks, Justin

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Justin Cooke wrote: I was always under the impression that a code other than 0 indicated an error. That's a hold-over from the DOS days. Read the docs for CDialog::EndDialog().


      "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

      J 1 Reply Last reply
      0
      • D David Crow

        Justin Cooke wrote: I was always under the impression that a code other than 0 indicated an error. That's a hold-over from the DOS days. Read the docs for CDialog::EndDialog().


        "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

        J Offline
        J Offline
        Justin Cooke
        wrote on last edited by
        #3

        OK. I've already taken a look at that info. I understand any int can be returned. How do I know what 2 means? In this case, I'm guessing it just means OnClose was called, but how do I know for sure? Is there a list of return codes somewhere? When I'm running with the debugger and I see nonzero codes, how can I tell if they indicate errors? Thanks for your help, Justin

        D 1 Reply Last reply
        0
        • J Justin Cooke

          OK. I've already taken a look at that info. I understand any int can be returned. How do I know what 2 means? In this case, I'm guessing it just means OnClose was called, but how do I know for sure? Is there a list of return codes somewhere? When I'm running with the debugger and I see nonzero codes, how can I tell if they indicate errors? Thanks for your help, Justin

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Look in winuser.h, about 3/4 of the way down.


          "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

          1 Reply Last reply
          0
          • J Justin Cooke

            Greetings, I have been using dialog based MFC apps for a while and just noticed that, at least in my applications, the exit codes aren't always 0 (even when things seem to be working correctly otherwise.) If I run any of my dialog apps from the debugger in VS 6.0, and I then close the app with either System->Close, Alt-F4, or the 'X', I see the following messages: The thread 0xBF4 has exited with code 2 (0x2). The program 'C:\Documents and Settings\justin.cooke\My Documents\MyProjects\randomNumGen\Debug\randomNumGen.exe' has exited with code 2 (0x2). If I instead close it with the OK or Cancel buttons, the exit codes are 0, as expected. What's going on? Does the 2 code just indicate how the app was closed? I was always under the impression that a code other than 0 indicated an error. I tried to find a list of what these codes mean in MSDN and online, but had no luck. Thanks, Justin

            M Offline
            M Offline
            Michael Dunn
            wrote on last edited by
            #5

            Thread and process exit codes have no inherent meaning, the code is just a DWORD that can be used for any purpose. As the other poster said, not every app will exit with 0; and if you see a nonzero exit code it doesn't imply an error happened. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- You cannot truly appreciate Dilbert unless you've read it in the original Klingon.

            J 1 Reply Last reply
            0
            • M Michael Dunn

              Thread and process exit codes have no inherent meaning, the code is just a DWORD that can be used for any purpose. As the other poster said, not every app will exit with 0; and if you see a nonzero exit code it doesn't imply an error happened. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- You cannot truly appreciate Dilbert unless you've read it in the original Klingon.

              J Offline
              J Offline
              Justin Cooke
              wrote on last edited by
              #6

              OK. Thanks for the info guys. I'll just stop wondering what a nonzero return means, unless I have another reason to suspect a problem. Thanks Again, Justin

              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