Einzelnen Beitrag anzeigen

Benutzerbild von OrallY
OrallY

Registriert seit: 29. Apr 2003
268 Beiträge
 
#1

Voller Pfad einer Anwendung anhand Handle

  Alt 5. Aug 2004, 17:13
Ich versuche den vollen Pfad einer Anwendung anhand des Handles herauszubekommen. Den Dateinamen kriege ich schon, allerdings nicht den Pfad dazu:


Delphi-Quellcode:
function GetProcessNameFromWnd(hWnd: HWND): string;
var
  ProcID : DWord;
  SSHandle : THandle;
  Continue : boolean;
  ProcEntry : TProcessEntry32;
begin
  GetWindowThreadProcessID(hWnd, @ProcID);
  SSHandle := CreateToolhelp32Snapshot(TH32CS_SnapProcess, 0);
  ProcEntry.dwSize := Sizeof(ProcEntry);
  // gehe alle Prozesse durch
  Continue := Process32First(SSHandle, ProcEntry);
  while Continue do begin
    // gesuchter Prozess (ProcID) in der Liste aller Prozesse gefunden?
    if ProcEntry.th32ProcessID = ProcID then
    begin
      Result := ProcEntry.szExeFile;
      break;
    end;
    Continue := Process32Next(SSHandle, ProcEntry);
  end;
  CloseHandle(SSHandle);
end;
.oO'rallY
Linux is like a tipi: no gates, no windows and a gnu-eating apache inside...
  Mit Zitat antworten Zitat