Home » VB.NetRSS

Getting the CPU's temperature in VB 2010 express

If this is possible i'm in need of the code snippet to be able to display the CPU's temperature in a listbox, any help will be appreciated.
 

7 Answers Found

 

Answer 1

Get CPU Temperature with VB.net

http://www.dreamincode.net/code/snippet2112.htm


' Specifies the format the temp should be returned inPublicEnum TempFormat
    Fahrenheit
    Celsius
    Kelvin
      ' The CPU temp will be returned in it's raw, uncalculated format
      Raw
  EndEnum' Gets the current temp of the CPU' <param name="Format">The temp scale the value should be returned in</param>PublicFunction GetCPUTemp(ByVal Format As TempFormat) AsSingleDim enumerator As System.Management.ManagementObjectCollection.ManagementObjectEnumerator
    Dim searcher AsNew System.Management.ManagementObjectSearcher("root\WMI", "SELECT * FROM MSAcpi_ThermalZoneTemperature")
    enumerator = searcher.Get.GetEnumerator()
    While enumerator.MoveNext
      Dim obj As System.Management.ManagementObject = CType(enumerator.Current, System.Management.ManagementObject)
      SelectCase format
        Case TempFormat.Fahrenheit
          ReturnCSng((obj.Item("CurrentTemperature") / 10 - 273.15) * 9 / 5 + 32)
        Case TempFormat.Celsius
          ReturnCSng(obj.Item("CurrentTemperature") / 10 - 273.15)
        Case TempFormat.Kelvin
          ReturnCSng(obj.Item("CurrentTemperature") / 10)
        Case TempFormat.Raw
          ReturnCSng(obj.Item("CurrentTemperature"))
      EndSelectEndWhileEndFunction

 

Answer 2

Hi,

In addition to Faraz,

There is a fine sample from Martin in this thread.

For both the now given answers you need to set a reference to System.Management and in the sample from Martin also an import for that.

Be aware that for the sample from Faraz you need to set option strict Off

http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/9d182655-4943-4b3d-bb2d-9de65fba18a1/

 

Answer 3

Unfortunately none of the codes i tried in my post and the topic in which Martin posted worked. Im running VB 2010 express  and this may be why, but im not sure, i've decided not to carry on with the project i was doing, how ever feel free to post more code snippets to help others who may need the answer to this question, and i may even come back to this at some point.
 

Answer 4

Instead of giving up please give the error details here. May be any one here might have encountered that error and have a solution for it.
 

Answer 5

Hello GENER-AL,

Thanks for your post.

As Faraz suggested, please try to post the error details, here the forum members will try their best to help you.

In addition, I searched a method about Reading CPU Temperature. Here is the link, please check. Hope it could make you get some ideas.

http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/18ce0701-e87d-4414-a8b5-8be3908a21b8  (Reading CPU Temperature (WMI))

If you have any comments, please feel free to follow up.

Wish you good luck.

Best regards,
Liliane
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com

 

Answer 6

Liliane,

The link you gave contains the same code which Martin has given (it is endless times in Microsoft forums).

It is blocked on my Window 7 computer, I thought it was on my computer, because I've not Asus probe installed.

But probably it is something from Windows 7 and Vista 

I saw that more persons are fighting with this, I did not really find a solution.

 

 

Answer 7

I tested it before and it worked fine. i tried it on my Desktop and try to run the both code provided above, return the same result

"Not supported" .

After that i downloaded a software Core Temp and it does show's the temperature.

Now i'm pretty sure its manufacturer dependent, since they will be accessed through an I/O port. If you have a specific board you're trying to work with, try looking through the manuals and/or contacting the manufacturer.

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter