We can get the system CPU temperature by using the ManagementObjectSearcher
class in the System.Management
namespace. Here's an example code snippet that gets the temperature in Celsius:
main.cs486 chars17 lines
This code queries the MSAcpi_ThermalZoneTemperature
class in the root\WMI
namespace to get the current CPU temperature. The temperature is returned in tenths of a Kelvin, so we need to subtract 2732.5 and then divide by 10 to get the Celsius temperature. Finally, the temperature is rounded to 2 decimal places and returned as a float.
gistlibby LogSnag