[Overview][Types][Classes][Variables][Index] | Reference for unit 'CustApp' (#fcl)

# TCustomApplication

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Ancestor class for TApplication classes.

## Declaration

Source position: custapp.pp line 30

`type TCustomApplication = class(TComponent)`
`public`
`constructor Create(); override;` |  | Create a new instance of the TCustomApplication class
`destructor Destroy; override;` |  | Destroys the TCustomApplication instance.
`procedure HandleException(); virtual;` |  | Handle an exception.
`procedure Initialize; virtual;` |  | Initialize the application
`procedure Run;` |  | Runs the application.
`procedure ShowException(); virtual;` |  | Show an exception to the user
`procedure Terminate();` |  | Terminate the application.
`function FindOptionIndex();` |  | Return the index of an option.
`function GetOptionValue();` |  | Return the value of a command-line option.
`function GetOptionValues();` |  | Get the values for an option that may be specified multiple times
`function HasOption();` |  | Check whether an option was specified.
`function CheckOptions();` |  | Check whether all given options on the command-line are valid.
`function GetNonOptions();` |  | Get all non-switch options
`procedure GetEnvironmentList();` |  | Return a list of environment variables.
`procedure Log();` |  | Write a message to the event log
`property ExeName: string; [r]` |  | Name of the executable.
`property HelpFile: string; [rw]` |  | Location of the application help file.
`property Terminated: Boolean; [r]` |  | Was Terminate called or not
`property Title: string; [rw]` |  | Application title
`property OnException: TExceptionEvent; [rw]` |  | Exception handling event
`property ConsoleApplication: Boolean; [r]` |  | Is the application a console application or not
`property Location: string; [r]` |  | Application location
`property Params []: string; [r]` |  | Command-line parameters
`property ParamCount: Integer; [r]` |  | Number of command-line parameters
`property EnvironmentVariable []: string; [r]` |  | Environment variable access
`property OptionChar: Char; [rw]` |  | Command-line switch character
`property CaseSensitiveOptions: Boolean; [rw]` |  | Are options interpreted case sensitive or not
`property StopOnException: Boolean; [rw]` |  | Should the program loop stop on an exception
`property ExceptionExitCode: LongInt; [rw]` |  | ExitCode to use then terminating the program due to an exception
`property EventLogFilter: TEventLogTypes; [rw]` |  | Event to filter events, before they are sent to the system log
`property SingleInstance: TBaseSingleInstance; [r]` |  | Single instance used to control single application instance behaviour
`property SingleInstanceClass: TBaseSingleInstanceClass; [rw]` |  | Class to use when creating single instance
`property SingleInstanceEnabled: Boolean; [rw]` |  | Enable single application instance control.
`end;`

## Inheritance

`TCustomApplication` |  | Ancestor class for TApplication classes.
`TComponent,IUnknown,IInterfaceComponentReference`
`TPersistent,IFPObserved`
`TObject`

## Description

TCustomApplication is the ancestor class for classes that wish to implement a global application class instance. It introduces several application-wide functionalities.

- Exception handling in HandleException, ShowException, OnException and StopOnException.
- Command-line parameter parsing in FindOptionIndex, GetOptionValue, CheckOptions and HasOption
- Environment variable handling in GetEnvironmentList and EnvironmentVariable.

Descendent classes need to override the DoRun protected method to implement the functionality of the program.

Documentation generated on: May 14 2021