我需要收集一些关于系统的信息用于我正在开发的应用程序。使用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;
}
}