Make Application.ExeName work in DLLs (Views: 101)
When you work with DLL you will discover that Application.ExeName will not return the DLL filename, but the filename of the application that loaded your library. That's a problem in some cases. You can use the GetModuleFileName to achieve this problem.
In Forms.pas, at line 6856 you'll find:
function TApplication.GetExeName: string;
Result := ParamStr(0);
for DLLs you can use this:
function GetRealExeName: string;
ExeName: array[0..MAX_PATH] of char;
fillchar(ExeName, SizeOf(ExeName), #0);
GetModuleFileName(HInstance, ExeName, MAX_PATH);
Result := ExeName;
now, this will return also DLL file names.
<< Back to main page