How to get the CPU Temperature info from Bios using c#?

倖福魔咒の 提交于 2020-01-01 09:12:20

问题


How to get the CPU Temperature info from Bios using c# I gave a try to the code in CPU temperature monitoring

But no luck. 'enumerator.Current' threw an exception.

How can i achieve this ? Thanks.

Error :

"This system doesn't support the required WMI objects(1) - check the exception file \r\nNot supported \r\n\r\n at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)\r\n at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext()\r\n at CedarLogic.WmiLib.SystemStatistics.RefreshReadings() in D:\Downloads\TempMonitorSrc\TemperatureMonitorSln\WmiLib\SystemStatistics.cs:line 25\r\n at CedarLogic.WmiLib.SystemStatistics.get_CurrentTemperature() in D:\Downloads\TempMonitorSrc\TemperatureMonitorSln\WmiLib\SystemStatistics.cs:line 87\r\n at TemperatureMonitor.SystemTrayService.CheckSupport() in D:\Downloads\TempMonitorSrc\TemperatureMonitorSln\TemperatureMonitor\SystemTrayService.cs:line 260"


回答1:


I would recommend the following approach. There are several free applications that monitor the CPU temp and display it. Try downloading some and then analyse the application to see what methods they are calling in order to discover how they work. Maybe they have a very different approach to your existing one. Also you might be able to just email them and ask how they did it...

http://www.alcpu.com/CoreTemp/

http://www.techpowerup.com/realtemp/

http://malektips.com/core-temp-cpu-windows-system-tray-taskbar.html




回答2:


You need to support many diffrent hardware sensors to gather temperature data. Better way is to take ready to use solutions like these:

1) Open Hardware Monitor - open source .NET 2.0 Application:

http://openhardwaremonitor.org/

2) Core Temp - free application and .NET API to get temperature data:

http:// www.alcpu.com/CoreTemp/developers.html




回答3:


I know this thread is old, but I wanted to add to it with a bit of a different approach. Get the make/model off the I/O chip on the motherboard and get the data sheet for said I/O chip (I will use an ITE IT8783F chip for reference here). Look under something like Environment Controller and calculate the access and read ports. Yes ... you will have to understand HEX and MSB and LSB and I won't go into the calculations/explanation here (out of scope). Now, in this instance the access port is 295 and the read port is 296. Reading further down in the section there is a table for the Environment Controller Registers. In this instance, the CPU temperature is in register 2Ah (or 0x2A). So, the VB/C# code I used to pull the info looks like this:

Private Function GetCPUTemp() As UInt32
    Dim tCpu As UInt32
    Dim stCpu As Short
    PortAccess.Outputb(&H295, &H2A)
    stCpu = PortAccess.Inputb(&H296)
    tCpu = CType(stCpu, UInt32)
    Return tCpu
End Function

Now, you just have to figure out what you want to do with it. Remember, if you find that you are getting crazy wacky numbers, you either are pulling from the wrong register or you may need to implement a scaling factor (as you do with voltage readings). This, too, should be in the data sheet.



来源:https://stackoverflow.com/questions/3614723/how-to-get-the-cpu-temperature-info-from-bios-using-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!