Find out where your program is running from
Sometimes it's necessary to find out the path to the executable file of your program, in order to find out where to get the rest of the files from. In most cases, the current directory would be the directory where your programs are executed from, but this method would not work if your program path is listed in the PATH or if an user executes your program from another directory.
Here's how to get the directory where your programs is located:
MessageDlg(
'program path = ' +
ExtractFilePath( Application.ExeName )
, mtInformation, [mbOk], 0 );
Listing #1 : Delphi code. Download
exepath (0.23 KB).
Applicable Keywords : Delphi, Delphi 1.x, Delphi 2.x, Delphi 3.x, Functions, Source Code