熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

列出C#進程以及詳細信息

2013-11-13 10:26:38  來源: .NET編程 
建立一個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); //不處理異常 }



From:http://tw.wingwit.com/Article/program/net/201311/13634.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.