tags:

views:

124

answers:

3

...Even when a user opens an application by double-clicking an associated file in a directory that's different from the executable. I've always used ExtractFilePath(Application.EXEName), but this function doesn't work as hoped in this circumstance.

A: 

Also try ParamStr(0). Maybe that works when application.exename doesn't?

Chris Thornton
That's exactly what the `ExeName` property returns.
Rob Kennedy
+5  A: 

ExeName returns ParamStr(0) which in turn returns the string produced by GetModuleFileName with hModule set to 0. I cannot see any reason why this wouldn't work in a normal application.

Andreas Rejbrand
A: 

ExePath := ExtractFilePath(paramstr(0));

I do it all the time, and it always works, whatever OS it is running on.

A.Bouchez