Get "executable" file name also from a DLL (Views: 101)
If you still use ParamStr(0), or Application.ExeName for getting your executable path and file name, you could have problems developing DLLs. In fact if your DLL enquires ParamStr(0) it gets the path and file name of the executable which loaded your DLL.
Using Application.ExeName is the same as using ParamStr(0), but there's a way to fix this and have the correct file name in every case.
Just use this:
function GetRealExeName: string;
ExeName: array[0..MAX_PATH] of char;
fillchar(ExeName, SizeOf(ExeName), #0);
GetModuleFileName(HInstance, ExeName, MAX_PATH);
Result := ExeName;
<< Back to main page