What code would let me find the compiled executable's directory? [closed]
...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开发者_Go百科 as hoped in this circumstance.
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.
Also try ParamStr(0). Maybe that works when application.exename doesn't?
ExePath := ExtractFilePath(paramstr(0));
I do it all the time, and it always works, whatever OS it is running on.
精彩评论