App object (only visual project type)

At run time, you have access to this interesting and useful object.

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. 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.

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

IMPORTANT: When working with Fasm visual projects, you must take into account that the App object is a structure, so it always has to be within brackets (i.e. [App.Previous]). If the App object is not within brackets, Fasm does not fire any error because it thinks an effective address is being passed, but the built application (or part of it) will not work.

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.