Enumerate Process via Error / Exception - Delphi

DarkCoderSc personal avatar
DarkCoderSc

Jean-Pierre LESUEUR

for var I := 0 to High(Cardinal) -1 do begin
    try
        var AProcessName := GetProcessName_QueryFullProcessImageName(I);
    
        WriteLn(Format('%s (%d)', [
          ExtractFileName(AProcessName),
          I
        ]));
    except
        // Ignore: GetProcessName_QueryFullProcessImageName raise exception on fail
    end;
end;

Creating and researching code snippets takes time and effort. You’re welcome to share them through your own platforms, but please don’t forget to credit the original author, here: Jean-Pierre LESUEUR.

Depends On


Created

April 14, 2025

Last Revised

May 14, 2025