Saturday, November 12, 2005 6:18 AMDoes anyone have the code for getting the cpu temps for a program?
Sunday, November 13, 2005 4:13 AMModeratornot all machines can support reading of the cpu temperature, it's a function of your BIOS software. Sometimes the bios manufacturer will supply dll's that you can reference to call the required function and return the details, when you reboot your computer get the bios manufacturer and model number and check and see if they support it.
Monday, November 14, 2005 10:45 PMUsing WMI may be the "cleanest" way of doing it, by reading the Win32_TemperatureProbe property:
This would need the OEM to have a driver for it, which I unfortunately think is more of the exception than the rule.
There's also this article abou this that doesn't sound good as for using the WMI:
It's unfortunate, as reading WMI data is supported by .NET classes in the Management namespace. See also here for that if you're still interested in digging here further: http://www.devcity.net/PrintArticle.aspx?ArticleID=144
If you wouldn't use WMI, I guess the alternative would be to work more low-level with SMBIOS data, possibly using undocumented methods that are incompatible from hardware to hardware. There are e.g. the tool Motherboard Monitor that comes with drivers IIRC to support various hardware, which shows there may unfortunately be no widely supported generic high-level API for this.
Monday, November 14, 2005 11:31 PMI'm not sure how manufacturer sensitive this is or that accessing bioses require a special dll.
This url has the most wonderful free motherbord monitor. The thing is, is that it's pretty universal with an extreme diversity of motherboards that it will function with.
The developer of this appears to just absolutely love hardware. I best if you wrote to him he'd tell you how it's done. I have a guess, just a guess if he responds with code, you will be looking at some fairely esoteric C.
This developer, im sure supplies a generic driver and tables of information about different mother boards.
Monday, April 17, 2006 4:55 PMsee this site....
Tuesday, December 18, 2007 9:34 AM
This works for me: (using System.Management, & System.Windows.Forms for the MessageBox)
ManagementClassprocessClass = new ManagementClass(@"root\WMI:MSAcpi_ThermalZoneTemperature");
foreach (ManagementObject service in processClass.GetInstances())
I found that with all of these posts, some aspects of the replies are right, but in some they fall short.
When you combine the expertise, you come out at something workable.
If you're trying to do the Win32_TemperatureProbe through WMI and you're getting nothing back, it is most likely that your motherboard doesn't have the appropriate driver, needed to expose the value.
If you check in Device Manager under System Devices, you should see ACPI Thermal Zone. If it's there, then the code above should return the current cpu temperature.
If your motherboard drivers exposed the necessary info, then this code from other forums probably would work for you:
SelectQuery myQuery = new SelectQuery("SELECT CurrentReading from Win32_TemperatureProbe");
ManagementObjectSearcher mySearcher = new ManagementObjectSearcher(myQuery);
foreach (ManagementBaseObject obj in mySearcher.Get())
MessageBox.Show("Temp: " + obj["CurrentReading"]);
Unfortunately it returns nothing on my box, and I don't have the resources here to test it on others.
But my feeling is that MSAcpi_ThermalZoneTemperature will work for you.
And btw, the output is in 10ths of Kelvin, so to convert, you can use this method...
staticdecimal ConvertToCelsius(string reading)
Tuesday, February 12, 2008 12:46 AM
Thursday, June 12, 2008 10:18 PMI found this VbScript works well.
Richard J. Rothery Jr.
- Edited by rjstinyc Thursday, June 12, 2008 10:21 PM Formatting
Friday, August 15, 2008 2:09 PMIt is impossible to only use VB to get CPU temperature. 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.
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.