App and Error objects (only visual project type)



At run time, you have access to these two interesting and useful objects.


App object

    The App object contains some information about the running application. It has the following members:

Accel The handle to the main accelerator table, if any, or NULL
CommandLine The command line (excluding the program name and path) for the application
FileName The name of the executable file
Header The header or title of the application (the text in the Header field of the project properties)
Instance The handle to the application's instance
Main The handle to the main window (start up window) of the application
Major The major version
Minor The minor version
Path The path to the application
Previous The handle to the main window of a previous instance, if any, or NULL
ProcessID The process identifier (not the process handle). To get the process handle, call the GetCurrentProcess API function.
Revision The revision of the version
ThreadID The identifier of the thread that created the main window.

Some applications can only have one instance running at a time (i. e. a CD Player). In order to know whether there is any other instance already running when you start the application, watch the App.Previous variable in the WM_CREATE message. If App.Previous is not NULL and you do not want another instance to run, return -1. The value of App.Previous is the handle to the main window of the running instance (if any), or NULL.


WARNING:
You should NEVER CHANGE none of the values of the App object or the application may crash.

REMARKS: The CommandLine member points to a null-terminated string specifying just the command line for the application (if any), that is, not including the program name and path. To retrieve the entire command line, use the API function GetCommandLine.


Error
object

    The Error object always stores information about the last exception occurred. It has one member:

Code

Error.Code is a DD variable which stores the code of the exception. The value in the Code member of the Error object is set to zero. When an exception occurs, its code is stored in the Code member of the Error object, and it will remain unmodified until another exception occurs. If you like, you can set Error.Code to zero before performing any operation.

REMARKS: Both objects, App and Error, are only available at run time.