码迷,mamicode.com
首页 > Windows程序 > 详细

C#获取WIN系统进程信息

时间:2014-08-20 01:15:37      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   io   for   ar   div   

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系统进程信息

标签:style   blog   color   os   io   for   ar   div   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!