1program testappexit; 2 3uses sysutils,custapp; 4 5type 6 TApplication = Class(TCustomApplication) 7 Procedure DoRun; override; 8 end; 9 10Procedure TApplication.DoRun; 11 12begin 13 ExceptionExitCode:=9; 14 If ParamStr(1)='-h' then 15 Terminate(10) 16 else if Paramstr(1)='-e' then 17 Raise Exception.Create('Stopping with exception') 18 else 19 Writeln('Normal stop'); 20 Terminate; 21end; 22 23begin 24 With TApplication.Create(Nil) do 25 try 26 StopOnException:=True; 27 Initialize; 28 Run; 29 finally 30 Free; 31 end; 32end.