Exit Code Level 2
-
Llasus wrote:
But I've noticed though that on an application it always returns the same exit code.
Is it your application or 3rd party? If it's yours, you should have control over what's returned :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
It depends on what type of application and whether or not it uses the CRT and/or MFC or other libraries. Could be main(), WinMain(), CWinApp::ExitInstance(), the exit code in a WM_QUIT message, etc. Somewhere, the app is exiting :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
It depends on what type of application and whether or not it uses the CRT and/or MFC or other libraries. Could be main(), WinMain(), CWinApp::ExitInstance(), the exit code in a WM_QUIT message, etc. Somewhere, the app is exiting :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
I see, I'll continue researching on MSDN docs about exit codes and see how it changes depending on my application. If you have links about exit codes though please give it to me. Again, thank you very much for your help!!! :-D
These are probably the most common places a return value is returned from... main: Program Startup[^] (Applies to all C/C++ apps) WinMain Function[^] (Applies to Win32 apps) CWinApp::ExitInstance[^] (Applies to MFC apps) CWinApp::Run[^] (Applies to MFC apps - if you've overriden Run(), the returned value can override ExitInstance() return value) PostQuitMessage Function[^] (Applies to all Windows applications) Note that many of these propogate up the list depending on the type of application. For example, in an MFC app, MFC has its own WinMain() and it's all handled by the CRT main() so you only have to worry about the return value from ExitInstance() or in rare circumstances, Run(). Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
These are probably the most common places a return value is returned from... main: Program Startup[^] (Applies to all C/C++ apps) WinMain Function[^] (Applies to Win32 apps) CWinApp::ExitInstance[^] (Applies to MFC apps) CWinApp::Run[^] (Applies to MFC apps - if you've overriden Run(), the returned value can override ExitInstance() return value) PostQuitMessage Function[^] (Applies to all Windows applications) Note that many of these propogate up the list depending on the type of application. For example, in an MFC app, MFC has its own WinMain() and it's all handled by the CRT main() so you only have to worry about the return value from ExitInstance() or in rare circumstances, Run(). Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Hi Mark. Thanks for your continuous help. I did some experiment and it actually worked by returning exit code 0. Though what I did may not be the right step. Since I don't really edit the ExitInstance() (as I have never used it before) I tried to check on my OnClose() function. By switching the original CDialog::OnClose() with PostQuitMessage(0), it actually returned the proper exit code of 0. But it may not be right since I forced it to return 0. Could you please check on this one?
void CApplicationDlg::OnClose() { SomeClass.CleanUp(); CWnd* ThisDlg; ThisDlg= GetDlgItem(IDC_LEFTPICBOX); ThisDlg->ReleaseDC(&GlobalLeftPicDC); GlobalLeftPicDC.DeleteDC(); ThisDlg= GetDlgItem(IDC_RIGHTPICBOX); ThisDlg->ReleaseDC(&GlobalRightPicDC); GlobalRightPicDC.DeleteDC(); CDialog::OnClose(); //Switch this with PostQuitMessage(0); }
I may be somehow going away from my problem here but I just want to prove that exit codes doesn't really have an effect on my program. Again, thank you for your help! -
Hi there. I created an application that on ending it displays: Program '[2788] Application.exe: Native' has exited with Code 2 (0x2). Now, from my research it said that the successful exit code should be 0. Has anyone had their programs exit with Code 2? Just want to ask so that I would have some clue on where to start finding the cause of this, if this does affect the application in the first place. thank you!
Llasus wrote:
Program '[2788] Application.exe: Native' has exited with Code 2 (0x2).
If it's a dialog-based application, are you dismissing the dialog via OK or Cancel?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Llasus wrote:
Program '[2788] Application.exe: Native' has exited with Code 2 (0x2).
If it's a dialog-based application, are you dismissing the dialog via OK or Cancel?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Llasus wrote:
Program '[2788] Application.exe: Native' has exited with Code 2 (0x2).
If it's a dialog-based application, are you dismissing the dialog via OK or Cancel?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
It relates to it 100%. Try it and see.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
It relates to it 100%. Try it and see.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne