如何获得CPU的温度?如何获得、温度、CPU

2023-09-02 01:24:56 作者:゛若爱丶会伤つ@

我需要收集的一些系统信息,我开发的应用程序。可用的存储器和CPU负载是容易得到使用C#。不幸的是,CPU温度就不是那么容易的。我已经使用WMI尝试,但用我无法得到任何

  Win32_TemperatureProbe
 

  MSAcpi_ThermalZoneTemperature
 

有没有人已经处理了这个问题?我想知道如何监测方案,SiSoftware Sandra里,都可以得到这些信息?

万一有人有兴趣,这里是类的code:

 公共类SystemInformation
{
    私人System.Diagnostics.PerformanceCounter m_memoryCounter;
    私人System.Diagnostics.PerformanceCounter m_CPUCounter;

    公共SystemInformation()
    {
        m_memoryCounter =新System.Diagnostics.PerformanceCounter();
        m_memoryCounter.CategoryName =记忆;
        m_memoryCounter.CounterName =可用的MB;

        m_CPUCounter =新System.Diagnostics.PerformanceCounter();
        m_CPUCounter.CategoryName =处理器;
        m_CPUCounter.CounterName =%处理器时间;
        m_CPUCounter.InstanceName =_Total;
    }

    公众持股量GetAvailableMemory()
    {
        返回m_memoryCounter.NextValue();
    }

    公众持股量GetCPULoad()
    {
        返回m_CPUCounter.NextValue();
    }

    公众持股量GetCPUTemperature()
    {
        // ...
        返回0;
    }
}
 
如何实时获取CPU温度,主板温度,显卡温度

解决方案

我是pretty的确定它的制造商依赖,因为他们将通过一个I / O端口进行访问。如果你有你想一个特定的电路板的工作,请阅读手册和/或制造商联系。

如果你想这样做了很多不同的板,我建议你联系的人在类似SiSoftware公司或是ppared阅读主板说明书很多$ P $。

作为另一个注意,不是所有的主板有温度监控。

您也可能会遇到越来越从内核访问特权的问题。

I need to gather some system's information for the application I'm developing. The memory available and the CPU load are easy to get using C#. Unfortunately, the CPU temperature it's not that easy. I have tried using WMI but I couldn't get anything using

Win32_TemperatureProbe

or

MSAcpi_ThermalZoneTemperature

Has anybody already dealt with this issue? I'm wondering how monitoring programs, as SiSoftware Sandra, can get that information...

Just in case anybody is interested, here is the code of the class:

public class SystemInformation
{
    private System.Diagnostics.PerformanceCounter m_memoryCounter;
    private System.Diagnostics.PerformanceCounter m_CPUCounter;

    public SystemInformation()
    {
        m_memoryCounter = new System.Diagnostics.PerformanceCounter();
        m_memoryCounter.CategoryName = "Memory";
        m_memoryCounter.CounterName = "Available MBytes";

        m_CPUCounter = new System.Diagnostics.PerformanceCounter();
        m_CPUCounter.CategoryName = "Processor";
        m_CPUCounter.CounterName = "% Processor Time";
        m_CPUCounter.InstanceName = "_Total"; 
    }

    public float GetAvailableMemory()
    {
        return m_memoryCounter.NextValue();
    }

    public float GetCPULoad()
    {
        return m_CPUCounter.NextValue();
    }

    public float GetCPUTemperature()
    {
        //...
        return 0;
    }
}

解决方案

I'm pretty sure it's manufacturer dependent, since they will be accessed through an I/O port. If you have a specific board you're trying to work with, try looking through the manuals and/or contacting the manufacturer.

If you want to do this for a lot of different boards, I'd recommend contacting someone at something like SiSoftware or be prepared to read a LOT of motherboard manuals.

As another note, not all boards have temperature monitors.

You also might run into problems getting privileged access from the kernel.