2008. szeptember 8., hétfő
Get FullPath Application of Any Object
Problem/Question/Abstract:
You want get app fullpath of any Object?
Answer:
uses psAPI;
procedure GetAppName(hWindow: THandle; var Buffer: string);
{
hWindow = Handle of the Object that you want know the path.
Buffer = variable that receive the fullpath.
}
var
dPID: dWord;
hHandle: THandle;
begin
GetWindowThreadProcessId(hWindow, @dPID); // Get PID of Object.
SetLength(Buffer, MAX_PATH); // Set Length of Buffer.
hHandle := OpenProcess(// Get Handle of Process.
PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,
true,
dPID
);
if GetModuleFileNameEx(// Check and get App FullPath Name.
hHandle,
0,
PChar(Buffer),
MAX_PATH
) > 0 then
SetLength(Buffer, StrLen(PChar(Buffer))); // If not reset Length of Buffer.
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése