type
TPROFILENAME = function(hProcess: THandle; lpFileName:LPTSTR; nSize: DWORD)WORD; stdcall;
var
Filename: TPROFILENAME;
....
procedure TForm1.Button1Click(Sender: TObject);
var
text: array[0..260] of Char;
dll: HMODULE;
proc: THandle;
begin
proc:= OpenProcess(PROCESS_QUERY_INFORMATION,False,StrToInt(Label2.Caption));
dll := LoadLibrary('C:\WINDOWS\system32\psapi.dll');
Filename := GetProcAddress(dll,'GetProcessImageFileNameW');
Filename(proc,PChar(@text),260);
ShowMessage(text);
CloseHandle(proc);
FreeLibrary(dll);
end;