我需要为我正在开发的应用程序收集一些系统信息.使用C#可以轻松获得可用内存和CPU负载.不幸的是,CPU温度并不那么容易.我尝试过使用WMI但是我无法使用任何东西
Win32_TemperatureProbe
Run Code Online (Sandbox Code Playgroud)
要么
MSAcpi_ThermalZoneTemperature
Run Code Online (Sandbox Code Playgroud)
有人已经处理过这个问题吗?我想知道像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;
}
}
Run Code Online (Sandbox Code Playgroud)