Registriert seit: 11. Apr 2006
152 Beiträge
|
Re: Pfad über Prozess
10. Sep 2006, 20:18
So habs!!
Delphi-Quellcode:
function GetProcessPath(Exename: string): String;
var
hProcSnap, hModSnap: THandle;
PE32: TProcessEntry32;
ME32: TModuleEntry32;
begin
Result := '';
hProcSnap := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);
if hProcSnap <> INVALID_HANDLE_VALUE then
begin
PE32.dwSize := SizeOf(ProcessEntry32);
if Process32First(hProcSnap, PE32) = true then
begin
while Process32Next(hProcSnap, PE32) = true do
begin
if Pos(Exename, PE32.szExeFile) <> 0 then
begin
hModSnap := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, PE32.th32ProcessID);
ME32.dwSize := SizeOf(TModuleEntry32);
Module32First(hModSnap, ME32);
Result := ME32.szExePath;
CloseHandle(hModSnap);
end;
end;
end;
CloseHandle(hProcSnap);
end;
end;
|
|
Zitat
|