|
-
Mar 9th, 2008, 02:04 PM
#1
Thread Starter
PowerPoster
Reading the Sensors in my PC? like Temp?
Hey guys I think 3rd party tools can read the temperature in my pc, but can VB read the heat sensors in my pc?
Thanks!
-
Mar 9th, 2008, 02:16 PM
#2
Re: Reading the Sensors in my PC? like Temp?
I don't know the answer to your question, but this link may get you started in a positive direction.
-
Mar 9th, 2008, 03:37 PM
#3
Re: Reading the Sensors in my PC? like Temp?
here is some code i used to get the cpu temperature
vb Code:
Dim wbemServices As Object Dim wbemObject As Object Dim wbemObjectSet As Object Dim wbemCounter As Integer Dim stemp As Long Set wbemServices = GetObject("winmgmts:" & "\\localhost\root\wmi") Set wbemObjectSet = wbemServices.InstancesOf("MSAcpi_ThermalZoneTemperature") For Each wbemObject In wbemObjectSet stemp = (wbemObject.CurrentTemperature - 2732) / 10 Next
note, this will only work with some motherboards if they support this temperature setup, also i could not verify if the result was actually correct,
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Mar 9th, 2008, 07:52 PM
#4
Thread Starter
PowerPoster
Re: Reading the Sensors in my PC? like Temp?
ok, but would I get the tempoerature into my label1?
-
Mar 9th, 2008, 09:20 PM
#5
Re: Reading the Sensors in my PC? like Temp?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Mar 11th, 2008, 02:09 AM
#6
Thread Starter
PowerPoster
Re: Reading the Sensors in my PC? like Temp?
lol Thank you, now this may be a dumb Q, but is this temp in C or f?
-
Mar 11th, 2008, 02:38 AM
#7
Frenzied Member
Re: Reading the Sensors in my PC? like Temp?
No expert on CPU temperatures, but I would say if it is under about 45 then it is in celcius. (To me 45 would be an extreme upper boundary (basically on fire ))
-
Mar 11th, 2008, 02:46 AM
#8
Re: Reading the Sensors in my PC? like Temp?
The clue is in westconn1's code. It looks as if the 'raw' temperature returned is tenths of degrees K.
(Current temp - 2732) / 10 will convert it to degrees C
-
Mar 11th, 2008, 05:29 AM
#9
Hyperactive Member
Re: Reading the Sensors in my PC? like Temp?
I'm using Vista 32-bit, the code returns "automation error" on this line
VB Code:
For Each wbemObject In wbemObjectSet
Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White
-
Mar 11th, 2008, 05:53 AM
#10
Re: Reading the Sensors in my PC? like Temp?
my guess would be that wbemobjectset had returned nothing
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Mar 11th, 2008, 06:09 AM
#11
Re: Reading the Sensors in my PC? like Temp?
Same thing here, I turned User Account Control off, re-booted and it seems to work ok now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|