Einzelnen Beitrag anzeigen

Delphi.Narium

Registriert seit: 27. Nov 2017
2.415 Beiträge
 
Delphi 7 Professional
 
#2

AW: Prüfen ob ein Prozess (noch) existiert

  Alt 21. Okt 2021, 13:16
Sowas in der Art?
Delphi-Quellcode:
uses
  TlHelp32;

function FindProcessByPid(const Pid : Cardinal) : Boolean;
var
  hProc, hSnapshot: THandle;
  Pe32: TProcessEntry32;
begin
  Result := false;
  hSnapshot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  Pe32.dwSize := SizeOf(TProcessEntry32);
  if Process32First(hSnapshot, Pe32) then begin
    repeat
      if pe32.th32ProcessID = Pid then begin
        Result := True;
        break;
      end;
    until not Process32Next(hSnapshot, Pe32);
  end;
  CloseHandle(hSnapshot);
end;
  Mit Zitat antworten Zitat