[英]How to get Free Memory and CPU usage without PerformanceCounter?
I have Windows XP which do not provide the Categories Processor or Memory, and I cannot bring it to show them (I'm not allowed to edit the registry nor to change System Files)我的 Windows XP 不提供类别处理器或内存,我不能带它来显示它们(我不允许编辑注册表或更改系统文件)
Is there any way to get the actual CPU usage and Free Memory without using PerformanceCounter?有没有办法在不使用 PerformanceCounter 的情况下获得实际的 CPU 使用率和可用内存?
I'm using .NET 3.5
and C#
on Windows XP SP2我在 Windows XP SP2 上使用
.NET 3.5
和C#
To get the Processor usage without performance counter using WMI, Look at win32_Processor class.要使用 WMI 获取没有性能计数器的处理器使用情况,请查看 win32_Processor 类。 and if you want to see the total memory available use
GC.GetTotalMemory - Process.GetCurrentProcess().PrivateMemorySize64
;如果您想查看可用内存总量,请使用
GC.GetTotalMemory - Process.GetCurrentProcess().PrivateMemorySize64
;
Would you be able to use native win32 API calls?您能否使用本机 win32 API 调用? If so then they would provide the information your after.
如果是这样,那么他们会提供您之后的信息。
See the following article: CodeProject: Calling API functions using C#请参阅以下文章: CodeProject:使用 C# 调用 API 函数
If you are using .net 4 and you are only interested in what your current app domain is doing then you can use this:如果您使用 .net 4 并且您只对您当前的应用程序域正在做什么感兴趣,那么您可以使用这个:
this.AppDomain.MonitoringTotalProcessorTime
See MSDN Documentation MonitoringTotalProcessorTime请参阅MSDN 文档 MonitoringTotalProcessorTime
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.