简体   繁体   English

如何在没有 PerformanceCounter 的情况下获得可用内存和 CPU 使用率?

[英]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.5C#

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.

相关问题 使用PerformanceCounter获取进程的CPU使用率 - Get CPU usage of process with PerformanceCounter 使用 PerformanceCounter 跟踪每个进程的内存和 CPU 使用情况? - Using PerformanceCounter to track memory and CPU usage per process? PerformanceCounter CPU使用率值始终为0 - PerformanceCounter CPU usage value allways 0 Performancecounter报告了不完整的CPU使用率值 - Performancecounter reporting werid CPU usage values PerformanceCounter CPU和内存,如任务管理器 - PerformanceCounter CPU & Memory like Task Manager 如何获取.Net Core 中进程的 CPU 使用率和虚拟 Memory? - How to get CPU Usage and Virtual Memory for a process in .Net Core? CPU 使用率与 Task Manager、PerformanceCounter 或 ManagementObjectSearcher 不匹配 - CPU usage does not match Task Manager, PerformanceCounter or ManagementObjectSearcher PerformanceCounter 报告的 CPU 使用率高于观察到的 - PerformanceCounter reporting higher CPU usage than what's observed 我正在使用PerformanceCounter获取进程内存使用情况。 如何以与任务管理器相同的单位显示内存使用情况? - I'm getting a process memory usage using PerformanceCounter. How can i display the memory usage in the same units as in task manager? 获取所有用户名的内存和 CPU 使用率 - Get Memory and CPU usage for all usernames
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM