网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

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
   {
       unsafepublicstaticDictionaryGetALLIO(Process procToRtrivIO)
       {
           IO_COUNTERS counters;
           Dictionary retCountIoDict=newDictionary();
           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
   {
       unsafepublicstaticDictionaryGetAllMem(Process procToRtrivMem)
       {

           PROCESS_MEMORY_COUNTERS*MemCounters;
           Dictionary retCountMemDict=newDictionary();
           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://bjjierui.cn/article/cddpdp.html

其他资讯