You can get the system CPU temperature in Fahrenheit using the following code in C# on a Windows machine:
main.cs646 chars24 linesIn the above code, we are using the ManagementObjectSearcher class to query the WMI (Windows Management Instrumentation) repository to get the current CPU temperature. The temperature value returned by WMI is in Kelvin, so we convert it to Fahrenheit using the formula (K - 273.15) * 1.8 + 32.
Note: The ManagementObjectSearcher class requires administrative privileges to access the WMI repository.
gistlibby LogSnag