mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
#include "util/windows/wmi.hpp"
|
|
|
|
extern "C"
|
|
const char* detectThermalTemp(double* current, double* critical)
|
|
{
|
|
// Requires Administrator privileges
|
|
// 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())
|
|
{
|
|
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;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
return "No WMI result returned";
|
|
}
|