Example Code

function GetProcessFileNameA(const hProcess: THandle; lpwcFileName: PAnsiChar): BOOL; stdcall; function GetProcessFileNameW(const hProcess: THandle; lpwcFileName: PWChar): BOOL; stdcall; // Arg1 process handle whose full filename is to be retrieved // Arg2 Output buffer of filename (MAX_PATH character) minimum var fileName: Array [0..MAX_PATH] of WChar; begin ZeroMemory(@fileName, sizeof(fileName)); if GetProcessFileNameW(GetCurrentProcess(), @fileName) then ShowMessage(Format('My current process filename is %s', [fileName])) else ShowMessage('GetProcessFileName failed!'); end;