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.
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.
Also, I need to be able to get the temperature of more than one GPU, as I have two.
What do I do?
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With