Spazio dei nomi:
using System;
using System.Diagnostics;
using System.Management;
C#
try
{
ManagementObjectSearcher ManObjSearcher = new ManagementObjectSearcher(@"root\WMI", "SELECT * FROM MSAcpi_ThermalZoneTemperature");
foreach (ManagementObject obj in ManObjSearcher.Get())
{
double temperaturaCPU = Convert.ToDouble(obj["CurrentTemperature"].ToString());
//Converte in Celsius
temperaturaCPU = (temperaturaCPU - 2732) / 10.0;
MessageBox.Show($"temperatura CPU: {temperaturaCPU} °C");
}
}
catch (Exception ex)
{
Console.WriteLine("Errore: " + ex.Message);
}
Nessun commento:
Posta un commento