Peter
Peter

Reputation: 1444

Exit code from C++ Builder Windowed (GUI) win32 application

I can't seem to find how to exit a (non console) Windowed application with a value. I was hoping this is a value I can set via TApplication, but not the case (that I can see).

I assume setting errorlevel via SetEnvironmentVariable() is futile, since on exit the program will overwrite this value (Not tested tbh)

The idea is to test this return value in a batch file via errorlevel

Following should be able to do that in the batch:

start /wait something.exe
echo %errorlevel%

Upvotes: 0

Views: 873

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 596527

You can either:

  • make your app's WinMain() function (found in your project's main .cpp file) return whatever value you want.

  • set the RTL's global ExitCode variable that is declared in System.hpp.

Upvotes: 4

Related Questions