C#實現進程內存信息獲取-創新互聯

usingSystem.Collections.Generic;
usingSystem.Runtime.InteropServices;
usingSystem;
usingSystem.Diagnostics;
staticclassNat
{
   [StructLayout(LayoutKind.Sequential]
   struct IO_COUNTERS
   {
       publiculongReadOperationCount;
       publiculongWriteOperationCount;
       publiculongOtherOperationCount;
       publiculongReadTransferCount;
       publiculongWriteTransferCount;
       publiculongOtherTransferCount;
   }
   [DllImport("kernel32.dll")]
   unsafestaticextern boolGetProcessIoCounters(IntPtrProcessHandle,out IO_COUNTERSIoCounters);

   [StructLayout(LayoutKind.Sequential,Size=40)]
   privatestruct PROCESS_MEMORY_COUNTERS
   {
       publicuint cb;
       publicuintPageFaultCount;
       publicuintPeakWorkingSetSize;
       publicuintWorkingSetSize;
       publicuintQuotaPeakPagedPoolUsage;
       publicuintQuotaPagedPoolUsage;
       publicuintQuotaPeakNonPagedPoolUsage;
       publicuintQuotaNonPagedPoolUsage;
       publicuintPagefileUsage;
       publicuintPeakPagefileUsage;
   }

   [DllImport("psapi.dll",SetLastError=true)]
   unsafestaticextern boolGetProcessMemoryInfo(IntPtr* hProcess,out PROCESS_MEMORY_COUNTERS*Memcounters,int size);

   publicstaticclass IO
   {
       unsafepublicstaticDictionary<string,ulong>GetALLIO(Process procToRtrivIO)
       {
           IO_COUNTERS counters;
           Dictionary<string,ulong> retCountIoDict=newDictionary<string,ulong>();
           IntPtr ptr=System.Diagnostics.Process.GetCurrentProcess().Handle;

           GetProcessIoCounters(ptr,out counters);
           retCountIoDict.Add("ReadOperationCount", counters.ReadOperationCount);
           retCountIoDict.Add("WriteOperationCount", counters.WriteOperationCount);
           retCountIoDict.Add("OtherOperationCount", counters.OtherOperationCount);
           retCountIoDict.Add("ReadTransferCount", counters.ReadTransferCount);
           retCountIoDict.Add("WriteTransferCount", counters.WriteTransferCount);
           retCountIoDict.Add("OtherTransferCount", counters.OtherTransferCount);
           return retCountIoDict;
           //return "This process has read " + ((counters.ReadTransferCount/1024)/1024).ToString("N0") +
           //   " Mb of data.";

       }
   }
   publicstaticclassMem
   {
       unsafepublicstaticDictionary<string,uint>GetAllMem(Process procToRtrivMem)
       {

           PROCESS_MEMORY_COUNTERS*MemCounters;
           Dictionary<string,uint> retCountMemDict=newDictionary<string,uint>();
           IntPtr ptr=System.Diagnostics.Process.GetCurrentProcess().Handle;

           GetProcessMemoryInfo(&ptr,outMemCounters,Marshal.SizeOf(typeof(PROCESS_MEMORY_COUNTERS)));//MemCounters.cb);
           retCountMemDict.Add("cb",MemCounters->cb);
           retCountMemDict.Add("PageFaultCount",MemCounters->PageFaultCount);
           retCountMemDict.Add("PeakWorkingSetSize",MemCounters->PeakWorkingSetSize);
           retCountMemDict.Add("WorkingSetSize",MemCounters->WorkingSetSize);
           retCountMemDict.Add("QuotaPeakPagedPoolUsage",MemCounters->QuotaPeakPagedPoolUsage);
           retCountMemDict.Add("QuotaPagedPoolUsage",MemCounters->QuotaPagedPoolUsage);

           retCountMemDict.Add("QuotaPeakNonPagedPoolUsage",MemCounters->QuotaPeakNonPagedPoolUsage);
           retCountMemDict.Add("QuotaNonPagedPoolUsage",MemCounters->QuotaNonPagedPoolUsage);
           retCountMemDict.Add("PagefileUsage",MemCounters->PagefileUsage);
           retCountMemDict.Add("PeakPagefileUsage",MemCounters->PeakPagefileUsage);

           return retCountMemDict;
           //return "This process has read " + ((counters.ReadTransferCount/1024)/1024).ToString("N0") +
           //   " Mb of data.";

       }
   }
}
C#實現進程內存信息獲取

 參考:using unsafe code in C# asp.net  http://stackoverflow.com/questions/17207310/using-unsafe-code-in-c-sharp-asp-net

創新互聯公司從2013年成立,是專業互聯網技術服務公司,擁有項目網站設計制作、成都網站建設網站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元塔什庫爾干塔吉克做網站,已為上家服務,為塔什庫爾干塔吉克各地企業和個人服務,聯系電話:18980820575

collectiong memory usage information for a processhttp://msdn.microsoft.com/en-us/library/windows/desktop/ms682050(v=vs.85).aspx

在C#中調用psapi.dll內置的GetProcessMemoryInfo函數http://social.microsoft.com/Forums/it-IT/650197e0-a21a-4f5e-a974-23f074f52a55/cpsapidllgetprocessmemoryinfo?forum=visualcshartzhchs

ASP.NET(C#)獲取當前計算機CPU內存使用率等相關信息http://luzinwbing.blog.163.com/blog/static/113805840201031093415658/

 不安全代碼只會在使用/unsafe編譯情況下使用 http://lixiaorong223.blog.163.com/blog/static/44011629200993181241924/

wmi獲得進程的虛擬內存與任務管理器中顯示的不一致 http://bbs.csdn.net/topics/260033107

文章標題:C#實現進程內存信息獲取-創新互聯
文章鏈接:http://m.kartarina.com/article18/cddpdp.html

成都網站建設公司_創新互聯,為您提供全網營銷推廣手機網站建設面包屑導航App設計網站排名關鍵詞優化

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

成都app開發公司
主站蜘蛛池模板: 国产在线无码视频一区二区三区| 亚洲毛片无码专区亚洲乱| 精品国产一区二区三区无码| 色AV永久无码影院AV| 中文无码字幕中文有码字幕| 久久精品无码一区二区三区日韩| 久久无码专区国产精品s| 亚洲av无码兔费综合| 国产成人无码精品一区二区三区| 熟妇人妻无码xxx视频| 无码人妻品一区二区三区精99| 精品久久久久久无码中文字幕一区| 夜夜添无码试看一区二区三区| 日韩久久无码免费毛片软件| 久久精品无码专区免费东京热| 无码人妻一区二区三区在线水卜樱 | 成人av片无码免费天天看| 亚洲国产成人精品无码区在线秒播 | 色噜噜综合亚洲av中文无码| 国产成人无码精品久久久久免费| 久久久无码人妻精品无码| 国产亚洲3p无码一区二区| 国产亚洲精品无码拍拍拍色欲 | 在线播放无码高潮的视频| 无码喷水一区二区浪潮AV| 亚洲综合无码无在线观看| 久久久久亚洲AV无码网站| 无码精品A∨在线观看| 亚洲成AV人片在线观看无码| 精品久久久久久无码人妻蜜桃| 国产免费午夜a无码v视频| 精品国产AV无码一区二区三区| 精品日韩亚洲AV无码一区二区三区| 国产免费无码一区二区| 人妻系列AV无码专区| 日日日日做夜夜夜夜无码| 波多野结衣AV无码| 大桥久未无码吹潮在线观看| 中文字幕在线无码一区 | 无码专区中文字幕无码| 亚洲av无码av制服另类专区|