Files
fastfetch/src/detection/cpu/cpu_windows.cpp
T

33 lines
1.0 KiB
C++
Raw Normal View History

2023-02-23 21:31:33 +08:00
#include "util/windows/wmi.hpp"
extern "C"
2024-09-24 11:09:51 +08:00
const char* detectThermalTemp(double* current, double* critical)
2023-02-23 21:31:33 +08:00
{
// Requires Administrator privileges
2023-02-23 21:31:33 +08:00
// https://wutils.com/wmi/root/wmi/msacpi_thermalzonetemperature/#properties
FFWmiQuery query(L"SELECT CurrentTemperature, CriticalTripPoint FROM MSAcpi_ThermalZoneTemperature WHERE Active = TRUE", nullptr, FFWmiNamespace::WMI);
if(!query)
return "Query WMI service failed";
if(FFWmiRecord record = query.next())
{
2023-06-25 14:16:49 +08:00
if (current)
{
if(auto vtCurrent = record.get(L"CurrentTemperature"))
*current = vtCurrent.get<int32_t>() / 10 - 273.15; // In tenth of degrees Kelvin
else
*current = 0.0/0.0;
}
if (critical)
{
if(auto vtCritical = record.get(L"CriticalTripPoint"))
*critical = vtCritical.get<int32_t>() / 10 - 273.15; // In tenth of degrees Kelvin
else
*critical = 0.0/0.0;
}
2023-02-23 21:31:33 +08:00
}
return "No WMI result returned";
}