///
/// 获得特定进程信息
///
/// 进程名称
public static void GetProcessInfo(string processName)
{
Process[] processes = Process.GetProcessesByName(processName);
foreach (Process instance in processes)
{
Console.WriteLine("");
Console.WriteLine("ProcessName:" + instance.ProcessName);
try
{
//单位:KB
Console.WriteLine("提交大小\t" + instance.PagedMemorySize64 / 1024);
Console.WriteLine("工作设置(内存)\t" + instance.WorkingSet64 / 1024);
Console.WriteLine("线程数\t" + instance.Threads.Count);
Console.WriteLine("句柄数\t" + instance.HandleCount);
}
catch { }
}
//PerformanceCounter TotalCpuUsage = new PerformanceCounter("Process", "% Processor Time", "Idle");
//double total1 = 0;
//while (true)
//{
// if (total1 == 0)
// {
// total1 = processes[0].TotalProcessorTime.TotalMilliseconds;
// }
// else
// {
// total1 += processes[0].TotalProcessorTime.TotalMilliseconds - total1;
// }
// Thread.Sleep(1000);
//}
}