下面的示例是演示了如何通过C#获取系统中所有进程的相关信息,包含名称和状态等。
using System;
using System.Diagnostics;
namespace ProcessStatus
{
class Program
{
static void Main(string[] args)
{
Process[] processes = Process.GetProcesses();
foreach (Process process in processes)
{
Console.WriteLine("Process Name: {0}, Responding: {1}", process.ProcessName, process.Responding);
}
Console.Write("press enter");
Console.ReadLine();
}
}
}