WMI always returns the same value

  • Thread starter Thread starter Alain Dekker
  • Start date Start date
A

Alain Dekker

Hi,

I'm using WMI and C++ to get the CPU temperature. It works, in the sense
that I get the temperature, but the same temperature is returned all the
time.

For example:
A) I run my program immediately the computer is booted. It returns, say,
23.0C. If I then run my program 2 hours later, it is still 23.0C.

B) I boot the computer, wait 30 minutes, then run the program. It returns,
say, 52.0C. Again, if I run it later, I always get that value.

How do I "kick" WMI and get it to update temperature values? Why does it get
locked?

Note: I'm using the namespace:
BSTR bstrNamespace = (L"root\\WMI");

and the query:
BSTR strQuery = (L"Select * from MSAcpi_ThermalZoneTemperature");

and the class property:
BSTR strClassProp = SysAllocString(L"CurrentTemperature");

If I use the "Win32_Processor" query and "LoadPercentage" property, this
DOES update every time I ask for it.

Many thanks,
Alain
 
I don't think there's anything you can do. This class is likely dependent
on the hardware vendor. Depending on hardware design and the provider
definition, this property may not update the way you think it should. It
could also depend on what sensors the motherboard includes. You might try a
3rd party tool like MotherBoard Monitor to see if your CPU temp really is
changing.

--
Jeffery Hicks
Microsoft PowerShell MVP
http://www.scriptinganswers.com
http://www.powershellcommunity.org

Now Available: WSH and VBScript Core: TFM
Coming Soon: Windows PowerShell: TFM 2nd Ed.
 
You must implement Monitor chip driver by C language. If mother-board
manufacturers implement WMI in their drivers, you can get CPU temperature
from WMI. So far as I know; no mother-board manufacturers implement WMI, so
WMI always returns the same value.
First, you need know what monitor chip on your mother-board. You may look
your mother-board. If you see LM75, LM78, Winbond ...etc trademark on your
chip, download the datasheet of your chip according to your number of chip.
The datasheet will show you how to access the chip.
This web site contains some source code about CPU temperature. The author
implemented monitor chip driver of W83697HF and W83627EHF which have Hardware
Monitor function.
http://temperature.myweb.hinet.net/index_en.htm The source code maybe help
you.
 
Back
Top