建立一个listBox将进程名称遍历进去
thislistBoxItemsClear();Process[] MyProcesses=ProcessGetProcesses();foreach(Process MyProcess in MyProcesses){thislistBoxItemsAdd(MyProcessProcessName);}thislistBoxSelectedIndex=;
选中listBox里面的项后将进程详细信息显示在右面的Label中
try{string ProcessName=thislistBoxText;thisgroupBoxText=ProcessName+进程的详细信息;Process[] MyProcess=ProcessGetProcessesByName(ProcessName);thislabelText=进程影象名+MyProcess[]ProcessName;thislabelText=进程ID+MyProcess[]Id;thislabelText=启动线程树+MyProcess[]ThreadsCountToString();thislabelText=CPU占用时间+MyProcess[]TotalProcessorTimeToString();thislabelText=线程优先级+MyProcess[]PriorityClassToString();thislabelText=启动时间+MyProcess[]StartTimeToLongTimeString();thislabelText=专用内存+(MyProcess[]PrivateMemorySize/)ToString()+K;thislabelText=峰值虚拟内存+(MyProcess[]PeakVirtualMemorySize/)ToString()+K;thislabelText=峰值分页内存+(MyProcess[]PeakPagedMemorySize/)ToString()+K;thislabelText=分页系统内存+(MyProcess[]PagedSystemMemorySize/)ToString()+K;thislabelText=分页内存+(MyProcess[]PagedMemorySize/)ToString()+K;thislabelText=未分页系统内存+(MyProcess[]NonpagedSystemMemorySize/)ToString()+K;thislabelText=物理内存+(MyProcess[]WorkingSet/)ToString()+K;thislabelText=虚拟内存+(MyProcess[]VirtualMemorySize/)ToString()+K;}catch(Exception Err){MessageBoxShow(没有此进程无法获取信息!信息提示MessageBoxButtonsOKMessageBoxIconInformation);//不处理异常 }