I can't get ExitCode to work for a VCL forms application. Here is my test application. It was created from the File / New menu in the Delphi 2007 IDE. The only change is that I added the line ExitCode := 42;
at the end.
program Test;
uses
Forms,
Unit27 in 'Unit27.pas' {Form27};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm27, Form27);
Application.Run;
ExitCode := 42;
end.
Now, when I run it from the command line, %ERRORLEVEL%
doesn't get set:
>.\Test.exe
>echo %ERRORLEVEL%
0
I was expected the value in %ERRORLEVEL%
to be 42, but it isn't being updated.
I tried the same experiment in a console application, and that worked fine. Why isn't it working for my GUI application?