Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Set Errorlevel On Exit of MFC App

I have an MFC legacy app that I help to maintain. I'm not quite sure how to identify the version of MFC and I don't think it would make a difference anyway.

The app can take some parameters on the command line; I would like to be able to set an errorlevel on exiting the app to allow a bat/cmd file to check for failure and respond appropriately.

I don't believe that exit() would work (hadn't tried it yet to be honest) because of the fact that this is an MFC app. Anyone know how to set the errorlevel returned by an MFC app? Can I just use exit()?

like image 966
Onorio Catenacci Avatar asked Dec 22 '22 14:12

Onorio Catenacci


1 Answers

I can't take credit for this so please don't up this reply.

CWinApp::ExitInstance(); return myExitCode;

This will return the errorlevel to the calling batch file for you to then evaluate and act upon.

like image 170
Lazarus Avatar answered Jan 02 '23 00:01

Lazarus