首页 > 系统服务 > 详细

获得特定进程信息

时间:2017-01-19 18:10:09      阅读:187      评论:0      收藏:0      [点我收藏+]

/// 
        /// 获得特定进程信息
        /// 
        /// 进程名称
        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);
            //}
        }

获得特定进程信息

原文:http://www.cnblogs.com/94cool/p/6307238.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!