Console applications are 32-bit programs that run without a graphical interface, in a console window. These applications typically don't require much user input and perform a limited set of functions. Any application that contains:
{$APPTYPE CONSOLE}
in the code opens a console window of its own.
To create a new console application, choose FileNewOther. Select Delphi Projects and double-click Console Application from the New Items dialog box.
The IDE then creates a project file for this type of source file and displays the Code editor.
Console applications should make sure that no exceptions escape from the program scope. Otherwise, when the program terminates, the Windows operating system displays a modal dialog with exception information. For example, your application should include exception handling such as shown in the following code:
program ConsoleExceptionHandling; {$APPTYPE CONSOLE} uses SysUtils; procedure ExecuteProgram; begin //Program does something raise Exception.Create('Unforeseen exception'); end; begin try ExecuteProgram; except //Handle error condition WriteIn('Program terminated due to an exception'); //Set ExitCode <> 0 to flag error condition (by convention) ExitCode := 1; end; end.
Users can terminate console applications in one of the following ways:
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|