using System;
using System.Diagnostics;
public Class AllProcess
{
public AllProcess( )
{
// TODO: Add Constructor Logic here
}
// 定义一个静太方法, 用于读取当前计算机的进程
public static void GetAllProcesses( )
{
int iCount = Process.GetProcesses( ).Length; // 取得进程数量
Process[ ] procList = new Process[ iCount ]; // 创建进程数组
procList = Process.GetProcesses( ) ; // 取得所有进程
for ( int i = 0 ; i < iCount; i ++ )
{
string strProcName = procList[ i ].ProcessName;
int iProcID = procList[ i ].Id ;
Console.WriteLine( strProcName + " : " + iProcID );
}
}
}