program ProcessesList;
uses Comobj;
var Wmi,Obj,Objs: OleVariant;
  i,ProcessTotal:Byte;
begin
  Wmi:= CreateOleObject('WbemScripting.SWbemLocator');
  Objs := Wmi.ConnectServer().InstancesOf('Win32_Process');
  ProcessTotal:=Objs.Count-1;
  Writeln(ProcessTotal);
  for i:=0 to ProcessTotal do
  begin
      Obj:=Objs.ItemIndex(i);
      Writeln(Obj.Name,'  ',Obj.ProcessID);
  end;
  readln;
end.