Author: Gilberto Saraiva
You want get app fullpath of any Object?
Answer:
1 uses psAPI;
2 3 procedure GetAppName(hWindow: THandle; var Buffer: string);
4 {5 hWindow = Handle of the Object that you want know the path.6 Buffer = variable that receive the fullpath.7 }8 var9 dPID: dWord;
10 hHandle: THandle;
11 begin12 GetWindowThreadProcessId(hWindow, @dPID); // Get PID of Object.13 SetLength(Buffer, MAX_PATH); // Set Length of Buffer.14 hHandle := OpenProcess(// Get Handle of Process.15 PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,
16 true,
17 dPID
18 );
19 if GetModuleFileNameEx(// Check and get App FullPath Name.20 hHandle,
21 0,
22 PChar(Buffer),
23 MAX_PATH
24 ) > 0 then25 SetLength(Buffer, StrLen(PChar(Buffer))); // If not reset Length of Buffer.26 end;