C#获取CPU温度

参考了WinRing0如何使用,这篇示例中较详细的描述了读取SIO芯片型号以及风扇转速(风扇的好像不行),

我再参考了[业余知识:PC 硬件监控]使用WinRing0 2.0.0.20读取CPU温度这篇博客,加入了获取CPU温度的代码。亲测可用~v~。主要增加代码如下:

 /// <summary>
/// CPU温度
/// </summary>
/// <returns></returns>
public int CpuTemp()
{
    uint eax, edx;
    eax = edx = 0;
    MyOls.Rdmsr(0x1A2, ref eax, ref edx);
    uint TjMax = eax;
    TjMax &= 0xFF0000;
    TjMax = TjMax >> 16;
    MyOls.Rdmsr(0x19C, ref eax, ref edx);
    uint IAcore = eax;
    IAcore &= 0xFF0000;
    IAcore = IAcore >> 16;
    int cputemp = (int)(TjMax - IAcore);
    return cputemp;
}

还有许多的API不清楚用法,待后续研究。我补充的代码