Reinventing the wheel

Product/Code Feedback => Delphi Tips/Articles/Examples => Topic started by: OK69 on April 02, 2009, 03:57:38 PM



Title: CPU Temperature
Post by: OK69 on April 02, 2009, 03:57:38 PM
Testing the code on this page ...

http://www.ciuly.com/delphi/wmi/cpuSystemTemperature/index.html

... i returned an error "Invalid class" when running these lines...
Code:
strQuery := 'SELECT * FROM __InstanceCreationEvent within 5 WHERE TargetInstance ISA "'+className+'"';
Services.ExecNotificationQueryAsync(SinkClasses.DefaultInterface, strQuery, 'WQL', 0, nil, nil);

... using Delphi 2007 (the variable "className" defined as "GTemperature").

Note: I imported the type libraries "Active DS Type Library 1.0" and "Microsoft WMI Scripting Library 1.2"


Title: CPU Temperature
Post by: ciuly on April 03, 2009, 09:51:34 PM
did you read the note on that page? :)
Quote

Note: works with GigaByte mainboards. maybe others, don't know.

the thing with WMI is that in order to have a certain functionality, one must have a WMI provider installed to provide that functionality. So, in order to read CPU temperature using WMI, you must have a WMI provider for your mainboard which will provide a class with that functinality. Class which can be called in any way. I suspect that the G from GTemperature coems from Gigabyte ;)
bottom line, you must find the class for your mainboards wmi provider that provides the CPU temperature. I never did try to find something generic. From what I remember, there are some WinAPI functions that can do this too. WMI_TemperatureProbe works on some systems as well. you just need to find the one taht works on your system. and if you try doing something for all systems, then you need to eitehr find something generic, OR, find most of the WMI classes and loop through them :)


Title: CPU Temperature
Post by: OK69 on April 04, 2009, 12:11:19 AM
Thank you very much for your help.

Greetings.