It is good to keep some programming tips we used.
To get the filename of the application, most of the time you can call:
sFileName := Application.ExeName; // or sFileName := ParamStr(0);
Perhaps you are working on a DLL and are interested in the filename of the DLL rather than the filename of the application, then you can use this function:
function Sto_GetModuleName: String;
var
szFileName: array[0..MAX_PATH] of Char;
begin
GetModuleFileName(hInstance, szFileName, MAX_PATH);
Result := szFileName;
end;
The above is from
http://www.martinstoeckli.ch/delphi/delphi.html#AppRedirectOutput