Page 1 of 1

[C++/CLI] Cum enumar procesele din sistem?

Posted: 31 Aug 2009, 00:13
by Ovidiu Cucu
Intrebare: Cum enumar procesele din sistem?

Raspuns: Folosind System::Diagnostics::Process.

Exemplu

Code: Select all

using namespace System;

int main(array<String ^> ^args)
{
   for each(Diagnostics::Process^ proc in Diagnostics::Process::GetProcesses())
   {
      if(proc->Id != 4 && proc->Id != 0) // Skip "System" & "Idle"
      {
         Console::WriteLine("Name: {0}", proc->ProcessName);
         Console::WriteLine("ID: {0}", proc->Id);
         Console::WriteLine("Executable path: {0}", proc->MainModule->FileName);
         // ...etc.
         Console::WriteLine("-----------------------------------------------");
      }
   }
   return 0;
}
Vezi si
Next FAQ >>