testappexit.pp 534 B

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