To get information about the currently running application in Delphi, you can use the ParamStr, ExeName, and GetModuleFileName functions from the System.SysUtils unit of the Delphi RTL. These functions provide an easy way to access various details about the application, such as the command line arguments, executable name, and file path.
Here is an example of how you can use these functions in Delphi to get information about the currently running application;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
uses System.SysUtils; var I Integer; Arguments TStringDynArray; ExecutableName string; FilePath string; begin Get the command line arguments Arguments = System.SysUtils.ParamStr(0).Split(‘ ‘); Writeln(‘Command Line Arguments’); for I = 0 to Length(Arguments) – 1 do Writeln(‘- ‘, Arguments[I]); Get the executable name ExecutableName = System.SysUtils.ExeName; Writeln(‘Executable Name ‘, ExecutableName); Get the file path SetLength(FilePath, MAX_PATH); SetLength(FilePath, GetModuleFileName(0, PChar(FilePath), MAX_PATH)); Writeln(‘File Path ‘, FilePath); end. |
This code sample uses the ParamStr, ExeName, and GetModuleFileName functions to get the command line arguments, executable name, and file path of the currently running application. You can use these and other functions from the System.SysUtils unit to access other information about the application, such as the version, build number, and product name. For more information, please refer to the Delphi documentation and the System.SysUtils unit reference.
Leave a Reply