Name
Halt Procedure
Syntax
procedure Halt(ExitCode: Integer);
Description
Halt
terminates an application immediately,
without giving it time to clean up after itself. Windows NT
automatically releases any resources that the application was using,
but Windows 95 and Windows 98 are less forgiving. Do not use
Halt
except in unusual circumstances, such as part
of a last-ditch, catch-all exception
handler.
Halt
is not a real procedure.
Tips and Tricks
Halt
saves its argument in the globalExitCode
variable.If the
ErrorAddr
variable is notnil
,Halt
prints an error message before it terminates the program.The
ExitProc
procedure and units’ finalization sections get to run before the program terminates.Halt
shuts down the program without freeing all objects and forms. A GUI application should close the main form to terminate the application instead of callingHalt
.
Example
// Report a run-time error at a specific address.
procedure ReportError(ErrorCode: Integer; Addr: Pointer);
begin
ErrorAddr := Addr;
if ErrorProc <> nil then
ErrorProc(ErrorCode, Addr);
Halt(ErrorCode);
end;
See Also
ErrorProc Variable, ExceptProc Variable, ExitCode Variable, ExitProc Variable, Finalization Keyword, NoErrMsg Variable, RunError Procedure |
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.