獲得當前計算機系統內所有的已啟動的進程:
System.Diagnostics.Process[] processOnComputer = System.Diagnostics.Process.GetProcesses();
foreach ( System.Diagnostics.Process p in processOnComputer )
{
System.Console.WriteLine(p.ToString());
}
Console.ReadLine();
獲得當前計算機系統內某個進程並關閉:
System.Diagnostics.Process[] process = System.Diagnostics.Process.GetProcessesByName("進程名稱");
foreach ( System.Diagnostics.Process p in process)
{
p.Kill();
}