( "root\\WMI", "SELECT * FROM MSAcpi_ThermalZoneTemperature"); foreach (ManagementObject obj in searcher.Get()) { double temperature = Convert.ToDouble(obj["CurrentTemperature"]) / 10.0 - 273.15; Console.WriteLine($"CPU Temperature: {temperature}°C"); } } catch (Exception ex) { ...
使用WMI查询硬件信息时,需要编写合适的查询语句(WQL),比如获取CPU温度的查询语句可能是查询“MSAcpi_ThermalZoneTemperature”类。 using System.Management; public int GetCpuTemperature() { int cpuTemp = -1; ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"root\WMI", "SELECT * FROM MSAcpi_...
ManagementBaseObject tempObject = enumerator.Current; raw = Convert.ToInt32(tempObject["CurrentTemperature"].ToString()); } double celsius = (raw / 10) - 273.15; Console.WriteLine("当前CPU温度:{0} ℃", celsius); } CPU的温度应该直接访问寄存器得到。但软件都在r...
以下是获取 CPU 温度的代码: defget_cpu_temperature():temperatures=psutil.sensors_temperatures()if'coretemp'intemperatures:forentryintemperatures['coretemp']:ifentry.label=='Package id 0':returnentry.currentreturnNonecpu_temperature=get_cpu_temperature()print(f"CPU 温度:{cpu_temperature}°C") 1. ...
, "SELECT * FROM MSAcpi_ThermalZoneTemperature"); ManagementObjectCollection.ManagementObject...
importohmwrapper.*;publicclassCpuTemperature{publicstaticvoidmain(String[]args){OHMWrapperwrapper=newOHMWrapper();if(!wrapper.open()){System.out.println("无法打开 Open Hardware Monitor。请确保程序已正确安装。");return;}OHMHardware[]hardware=wrapper.getHardware();for(OHMHardwareh:hardware){if(h.get...
[i].HardwareType ==HardwareType.CPU)36{37for(intj =0; j < computer.Hardware[i].Sensors.Length; j++)38{39if(computer.Hardware[i].Sensors[j].SensorType ==SensorType.Temperature)40Console.WriteLine(computer.Hardware[i].Sensors[j].Name +":"+ computer.Hardware[i].Sensors[j].Value.ToString...
python get_cpu_temperature.py ``` 5.查看输出结果: 运行代码后,将会输出CPU的温度数据,例如: ``` CPU温度:45.0°C CPU温度:43.0°C CPU温度:47.0°C ... ``` 通过以上步骤和示例代码,您可以使用psutil库在Windows系统下轻松地获取电脑的CPU温度数据。psutil库提供了丰富的系统信息获取功能,您还可以根据自己...
python get_cpu_temperature.py ``` 5.查看输出结果: 运行代码后,将会输出CPU的温度数据,例如: ``` CPU温度:45.0°C CPU温度:43.0°C CPU温度:47.0°C ... ``` 通过以上步骤和示例代码,您可以使用psutil库在Windows系统下轻松地获取电脑的CPU温度数据。psutil库提供了丰富的系统信息获取功能,您还可以根据自己...
System.Text; using System.Threading.Tasks; using OpenHardwareMonitor.Hardware; namespace Get_CPU_Temp...