Einzelnen Beitrag anzeigen

Shark99

Registriert seit: 16. Mai 2007
403 Beiträge
 
#10

Re: Code funktioniert mit WindowsXP, nicht mit WindowsXP 64

  Alt 15. Dez 2008, 10:52
Hab hier eine fast komplette Lösung:

Delphi-Quellcode:
function DevicePathToWin32Path(path:string):string;
var c:char;
    s:string;
    i:integer;
begin
  i:=posex('\', path, 2);
  i:=posex('\', path, i+1);
  result:=copy(path, i, length(path));
  delete(path, i, length(path));
  for c:='Ato 'Zdo
  begin
    setlength(s, 1000);
    if querydosdevice(pchar(string(c)+':'), pchar(s), 1000)<>0 then
    begin
      s:=pchar(s);
      if sametext(path, s) then
      begin
        result:=c+':'+result;
        exit;
      end;
    end;
  end;
  result:='';
end;


function GetProcessFilePath(pid:cardinal):string;
var
  hp: THandle;
  Buffer1: array[0..MAX_PATH] of Char;
begin
  Result := '';

  if pid > 0 then
  begin
    hp := OpenProcess(PROCESS_ALL_ACCESS,False,pid);

    if hp > 0 then
    begin
        if IsWinNT4 or IsWin2K then
        begin
             if GetModuleFileNameEx(hp,0,Buffer1,Length(Buffer1)) > 0 then
               Result := PathGetLongName(
                              StringReplace(
                                             ExtractFilePath( Buffer1 ),
                                             '\??\', '', [rfReplaceAll, rfIgnoreCase]
                                           )
                                        );
        end else
        begin
             GetProcessImageFileName(hp, Buffer1, Length(Buffer1));

             Result := PathGetLongName(
                              StringReplace(
                                             ExtractFilePath(
                                                  DevicePathToWin32Path(Buffer1)
                                                            ),
                                             '\??\', '', [rfReplaceAll, rfIgnoreCase]
                                           )
                                      );
        end;
        CloseHandle(hp);
    end;
  end;
end;
Leider startet die Exe mit Windows 2000 erst gar nicht (GetProcessImageFileNameA entry point not found).
  Mit Zitat antworten Zitat