C#得到系統(tǒng)進程和結束某個指定的進程

2010-08-28 10:50:01來源:西部e網(wǎng)作者:

獲得當前計算機系統(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();
}

關鍵詞:C#