Thema: Delphi Pfad über Prozess

Einzelnen Beitrag anzeigen

Benutzerbild von MuTzE.Y85
MuTzE.Y85

Registriert seit: 11. Apr 2006
152 Beiträge
 
#4

Re: Pfad über Prozess

  Alt 10. Sep 2006, 19: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;
  Mit Zitat antworten Zitat