Einzelnen Beitrag anzeigen

Blacklotus

Registriert seit: 7. Jun 2003
13 Beiträge
 
#1

Process Pfad unter XP ermitteln

  Alt 7. Jun 2003, 12:16
Hallo bin neu hier und hab da mal ne Frage

Ich will den Pfad der explorer.exe ermitteln. Unter Win 9X,ME scheint das kein Problem zu sein aber unter Win2K,XP bekomme ich nur den Dateinamen zurück. Hier mal ein Code Schnipsel

Delphi-Quellcode:
var
   NTPID:TProcessrecs;
   win : HWND;
   tempString: array[0..255] of Char;
   i,j : Integer;
   ProcID : DWord;
   SSHandle : THandle;
   Contin : boolean;
   ProcEntry : TProcessEntry32;
   temp:string;
   bWinNT:boolean;
begin
Dir := '';
Version := '';
bWinNT := WinNT;

win := GetTopWindow(0);
     tempString := '';
     for i := 0 to 255 do begin
      win := GetNextWindow(win,GW_HWNDNEXT);
      GetWindowText(win, tempString, 255);
     if (Pos('EXPLORER', Uppercase(tempString)) = 0) then
     continue
      else
      begin
      if GetOSName <> 'Windows NTthen begin
  GetWindowThreadProcessID(FindWindow(nil,tempstring), @ProcID);
  SSHandle := CreateToolhelp32Snapshot(TH32CS_SnapProcess, 0);
  ProcEntry.dwSize := Sizeof(ProcEntry);
  Contin := Process32First(SSHandle, ProcEntry);
  while Contin do begin
    if ProcEntry.th32ProcessID = ProcID then
    begin
      Temp := Uppercase(ProcEntry.szExeFile)else
      if (Pos('EXPLORER',Temp) <>0) then
      if bWinNT then begin
      Dir := '';
      Version := tempstring;
      result := ProcEntry.th32ProcessID;
      exit;
      end else
      begin
      Dir := Extractfilepath(ProcEntry.szExeFile);
      Version := tempstring;
      result := ProcEntry.th32ProcessID;
Danke
  Mit Zitat antworten Zitat