Board index » delphi » getting path of .exe

getting path of .exe

I once came across a function to extract the path to the executable of a
program, but I don't know where. Does anyone know what function I should
use?

Thanks,
r3tina

--
remove NOSPAM- from email to reply
The engines of creation - Quake maps & tools
www.planetquake.com/eoc

 

Re:getting path of .exe


Use:

ExtractFilePath(Application.ExeName);

"r3tina" <r3t...@nospam-planetquake.com> schreef in bericht
news:3a227ca4$0$15711@reader5...

Quote
> I once came across a function to extract the path to the executable of a
> program, but I don't know where. Does anyone know what function I should
> use?

> Thanks,
> r3tina

> --
> remove NOSPAM- from email to reply
> The engines of creation - Quake maps & tools
> www.planetquake.com/eoc

Re:getting path of .exe


An old pascal trick I used to use at run-time was

Var PathOfRunningEXE : String;

PathOfRunningEXE := ParamStr(0);

As far as I know this still works under Delphi.

Cheers

Gareth

Re:getting path of .exe


Quote
Gareth wrote:
> An old pascal trick I used to use at run-time was

> Var PathOfRunningEXE : String;

> PathOfRunningEXE := ParamStr(0);

> As far as I know this still works under Delphi.

> Cheers

> Gareth

yes, you're right... but not quite :)
because ParamStr(0) contains a full path with filename (like this -
c:\somefolder\yourapp.exe)

to get _path_ you should use this:

ExtractFilePath(ParamStr(0));

OR, there is another way:

PathOfRunningEXE := ExtractFilePath(Application.ExeName);

regards, Igor

Other Threads