【发布时间】:2009-07-28 16:03:50
【问题描述】:
我需要为我正在开发的应用程序收集一些系统信息。使用 C# 很容易获得可用内存和 CPU 负载。不幸的是,CPU温度并不是那么容易。我曾尝试使用 WMI,但我无法使用任何东西
Win32_TemperatureProbe
或
MSAcpi_ThermalZoneTemperature
我该怎么做?我想知道作为 SiSoftware Sandra 的监控程序如何获取这些信息...
这是类的代码:
public class SystemInformation
{
private System.Diagnostics.PerformanceCounter m_memoryCounter;
private System.Diagnostics.PerformanceCounter m_CPUCounter;
public SystemInformation()
{
m_memoryCounter = new System.Diagnostics.PerformanceCounter();
m_memoryCounter.CategoryName = "Memory";
m_memoryCounter.CounterName = "Available MBytes";
m_CPUCounter = new System.Diagnostics.PerformanceCounter();
m_CPUCounter.CategoryName = "Processor";
m_CPUCounter.CounterName = "% Processor Time";
m_CPUCounter.InstanceName = "_Total";
}
public float GetAvailableMemory()
{
return m_memoryCounter.NextValue();
}
public float GetCPULoad()
{
return m_CPUCounter.NextValue();
}
public float GetCPUTemperature()
{
//...
return 0;
}
}
【问题讨论】:
-
如果你愿意付钱,我会考虑 cpuid-pro.com,如果我没记错的话,它与
z-cpu使用的是同一个库..