Click here to Skip to main content
16,020,459 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey

Do you know someone a very simple way of getting the temperature of the CPU?
I know that the Internet is a lot of solutions, but:

1 Solutions based on WMI but I can not get work, the temperature is empty.
2 Open Hardware Monitor is too complicated for my needs.

I need a banal windows program that showed the CPU temperature in the textbox and that's all.

Thank you for any help!
Posted
Comments
Kenneth Haugland 24-Oct-13 4:41am    
Perhaps it is dependent on the driver of some of them?
Mehdi Gholam 24-Oct-13 4:51am    
WMI is the simplest way to do it.

1 solution

Briefly translated from VB code in a quick basic search:
C#
public class Form1
{
   private void Button1_Click(object sender, EventArgs e)
   {
      try {
         ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"root\WMI", "SELECT * FROM MSAcpi_ThermalZoneTemperature");
         foreach (ManagementObject queryObj in searcher.Get()) {
            double temp = double.Parse(queryObj["CurrentTemperature"]);
            temp = (temp - 2732) / 10d;
            MessageBox.Show(temp.ToString());
      }
      catch (ManagementException err) {
         MessageBox.Show("An error occurred while querying for WMI data: " + err.Message);
      }
   }
}


WMI Administrative Tools[^] could be of great help, too.
 
Share this answer
 
Comments
stockCoders 24-Oct-13 7:19am    
Solution 1, also show me empty value

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900