C#CPU和GPU温度 [英] C# CPU and GPU Temp
问题描述
我正在为系统性能创建个人监控程序,但在弄清楚C#如何检索CPU和GPU温度信息时遇到了问题。
I'm in the process of creating a personal monitoring program for system performance, and I'm having issues figuring out how C# retrieves CPU and GPU Temperature information.
我已经有程序通过PerformanceCounter检索CPU负载和频率信息(以及其他各种信息),但是我找不到该实例, CPU温度的对象和计数器变量。
I already have the program retrieve the CPU Load and Frequency information(as well as various other things) through PerformanceCounter, but I haven't been able to find the Instance, Object,and Counter variables for CPU temp.
另外,我需要能够获得一个以上GPU的温度,因为我有两个。
Also, I need to be able to get the temperature of more than one GPU, as I have two.
我该怎么办?
推荐答案
您可以使用WMI为此,有一个WMI的ac#代码生成器,在创建WMI查询时会很有帮助,因为它没有被很好地证明。
You can use the WMI for that, there is a c# code generator for WMI that helps a lot when creating WMI quires as it is not documented that well.
可以在此处找到WMI代码生成器: http://www.microsoft.com/en-us/ download / details.aspx?id = 8572
The WMI code generator can be found here: http://www.microsoft.com/en-us/download/details.aspx?id=8572
快速尝试会生成如下内容:
a quick try generates something like this:
public static void Main()
{
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\WMI",
"SELECT * FROM MSAcpi_ThermalZoneTemperature");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("MSAcpi_ThermalZoneTemperature instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("CurrentTemperature: {0}", queryObj["CurrentTemperature"]);
}
}
catch (ManagementException e)
{
MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
}
}
这可能并不是您真正需要的,只是尝试一下带有可用的属性和类
This may not be exactly what you need just try around with the properties and classes available
这篇关于C#CPU和GPU温度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!