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

Limbajul C++/CLI, applicatii mixed-mode sau probleme specifice .NET legate de C++ (forum moderat)
Post Reply
User avatar
Ovidiu Cucu
Fondator
Fondator
Posts: 3776
Joined: 11 Jul 2007, 16:10
Judet: Iaşi
Location: Iasi

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

Post by Ovidiu Cucu » 31 Aug 2009, 00:13

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 >>



Post Reply