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 the EC Player example coming with Easy Code). In Order to know if 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.

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.


    The Error object always stores information about the last exception occurred. It has two members:


Error.Code is a DWord variable which stores the code of the exception, while Error.Description is a pointer to the effective address of a null-terminated string which stores the description of the exception (this member is only available in Debug mode). The values in the Error object are set to zero (Code member) and to an empty string (Description member) when the application starts. When an exception occurs, its code and description are stored in the corresponding members of the Error object, and they will remain unmodified until another exception occurs. If you like, you can set Error.Code to zero before performing any operation, but you should NEVER CHANGE the Error.Description address.

REMARKS: Both objects are only available at run time. When working in Release mode only Error.Code is available, as Error.Description exists but it is never updated in the ECStcMsr.lib or ECDllMsr.lib libraries.