首页 > Windows开发 > 详细

C#获取WIN系统进程信息

时间:2014-08-20 01:15:37      阅读:367      评论:0      收藏:0      [点我收藏+]
private void button1_Click(object sender, EventArgs e)
        {
            listBox_thread_list.Items.Clear();
            Process[] processes;
            processes = System.Diagnostics.Process.GetProcesses();
            Process process;
            for (int i = 0; i < processes.Length; i++)
            {
                
                process = processes[i];
               // str = str + Convert.ToString(process.Id) + ": "+process.ProcessName+"\r\n";
                listBox_thread_list.Items.Add(process.Id + ":"+process.ProcessName);
               
            }

            //System.Windows.Forms.MessageBox.Show(str);
           // textBox_thread_list.Text = processes[0].ProcessName.ToString();
            
        }

        private void get_this_thread_Click(object sender, EventArgs e)
        {
            string item = null;
            try
            {
                item = listBox_thread_list.SelectedItem.ToString();
                
            }catch (ArgumentException e1)
            {
                throw new ArgumentException("出错啦!", e1);
            }
            string[] items = item.Split(new Char[]{:});
            int thread_id = Convert.ToInt32(items[0]);
            string thread_name = items[1];
            long thread_RAM = Process.GetProcessById(thread_id).WorkingSet64;
            using (var private_RAM = new PerformanceCounter("Process", "Working Set - Private", thread_name))
            System.Windows.Forms.MessageBox.Show("线程ID:" + thread_id + "\n线程名:" + thread_name + "\n线程工作集:" + (thread_RAM) / 1024 + "Kb" + "\n线程专用内存:" + (private_RAM.NextValue() / 1024) + "Kb");
        }

 

C#获取WIN系统进程信息,布布扣,bubuko.com

C#获取WIN系统进程信息

原文:http://www.cnblogs.com/owl-home/p/3923560.html

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