Thema: Delphi Prozessinfos

Einzelnen Beitrag anzeigen

MartinA

Registriert seit: 27. Aug 2003
13 Beiträge
 
#2

Re: Prozessinfos

  Alt 6. Jul 2006, 15:06
Zitat von silent vapor:
Geht das nicht irgendwie in einem Zweizeiler? Das Programm soll so klein wie möglich werden.
Nuja mit einem Zweizeiler nicht ...

Code:
uses TlHelp32,PsAPI

function Execheck(exename:string): string;
var
  aSnapshotHandle: THandle;
  ContinueLoop: BOOL;
  aProcessEntry32: TProcessEntry32;
  handle : thandle;
begin
  aSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  aProcessEntry32.dwSize := Sizeof(aProcessEntry32);
  result := '';
  ContinueLoop := Process32First(aSnapshotHandle, aProcessEntry32);
  handle := 0;
  while integer(ContinueLoop) <> 0 do
    begin
      if (Exename = aProcessEntry32.szExeFile) then
        begin
          Handle := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, aProcessEntry32.th32ProcessID);
          if Handle <> 0 then
            begin
              SetLength(Result, MAX_PATH);
              if GetModuleFileNameEx(Handle, 0, PChar(Result), MAX_PATH) > 0 then
                SetLength(Result, StrLen(PChar(Result)))
              else
                Result := '';
              CloseHandle(Handle);
            end;
        end;
      ContinueLoop := Process32Next(aSnapshotHandle, aProcessEntry32);
    end;
  CloseHandle(aSnapshotHandle);
end;
ALT +F4
  Mit Zitat antworten Zitat