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