C#获取WIN系统进程信息

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

上一篇:Web Api系列教程第2季(OData篇)(二)——使用Web Api创建只读的OData服务


下一篇:关于linux挂载window下共享文件