列出C#进程以及详细信息

列出C#进程以及详细信息,第1张

列出C#进程以及详细信息,第2张

设置一个listBox来遍历进程名
this . listBox 1 . items . clear();
Process[]my processes = Process。get processes();
foreach(在MyProcesses中处理my Process)
{
this . listbox 1 . items . add(my Process。process name);
}
this . listbox 1 . selectedindex = 0;
在listBox中选择该项后,右边的标签中将显示流程详细信息
try
{
string process name = this . listBox 1 . text;
this . group box 1 . text = process name+"进程的详细信息";
Process[]my Process =进程。GetProcessesByName(进程名);
this.label1.Text= "进程影子名称:"+MyProcess[0]。ProcessName
this.label2.Text= "进程id:"+myprocess [0]。id;
this.label3.Text= "启动线程树:"+myprocess [0]。threads . count . tostring();
this . label 4 . text = " CPU time:"+my process[0]。totalprocesstime . tostring();
this.label5.Text= "线程优先级:"+myprocess [0]。priority class . tostring();
this . label 6 . text = " start time:"+my process[0]。start time . tolongtimestring();
this.label7.Text= "私有内存:"+(myprocess [0])。privatemorysize/1024)。tostring()+" k ";
this.label8.Text= "峰值虚拟内存:"+(myprocess [0])。peakvirtualmemorysize/1024)。tostring()+" k ";
this.label9.Text= "峰值分页内存:"+(myprocess [0])。peakpagedmemorysize/1024)。tostring()+" k ";
this.label10.Text= "分页系统内存:"+(myprocess [0])。pagedSystemMemory Size/1024)。tostring()+" k ";
this.label11.Text= "分页内存:"+(myprocess [0])。页面内存大小/1024)。tostring()+" k ";
this.label12.Text= "非分页系统内存:"+(myprocess [0])。nopagedsystemmemorysize/1024)。tostring()+" k ";
this.label13.Text= "物理内存:"+(myprocess [0])。workingset/1024)。tostring()+" k ";
this.label14.Text= "虚拟内存:"+(myprocess [0])。虚拟内存大小/1024)。tostring()+" k ";
}
catch(exception err)
{
messagebox . show("没有这个过程就无法获取信息!",“信息提示”,messageboxbuttons.ok,messagebox icon . information);
//没有异常处理
}

位律师回复
DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
白度搜_经验知识百科全书 » 列出C#进程以及详细信息

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情