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

房东的猫 提交于 2019-12-04 03:25:47

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

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

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.

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