Enum Process Method 1

March 3, 2020
Delphi, CreateToolHelp32Snapshot, List Process, Process Enum, Process32First, TProcessEntry32

This is one of the most famous method to enumerate running process on Windows. If AFilterSameArch is set to True, only processes running with same architecture as current process will be listed. { Jean-Pierre LESUEUR (@DarkCoderSc) Example: ... var AProcessName : String; AProcessId : Cardinal; AProcessList : TDictionary<Integer, String>; begin AProcessList := EnumProcess(True); try for AProcessId in AProcessList.Keys do begin if NOT AProcessList.TryGetValue(AProcessId, AProcessName) then continue; /// ... end; finally if Assigned(AProcessList) then FreeAndNil(AProcessList); end; end; } //. ...