Chapter 2. Environment information

Table of Contents

X2UtApp.pas
X2UtOS.pas

X2UtApp.pas

Contains a TX2App class which can be initiated as a singleton using the App() function. It provides information related to the application, such as the executable path and version information.

Note that you should not free the return value of the App() function, the unit's finalization clause takes care of destroying the object when the application closes. This makes it suitable to use the App() function in a way similar to Delphi's Application object.

Example 2.1. Using the App function

MyDataFileLocation := App.Path + 'data.ini';

The version information is accessible through App.Version. It contains the version numbers and various build flags as specified in the project options. You can also access the version strings through App.Version.Strings, which contain information such as the product name and copyright.

Useful for display purposes is the App.FormatVersion() function. It returns a string with the version information in the format "vX.X.X". If the optional Build parameter is set to True (default), "build X" is appended as well.