mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-31 18:13:38 +01:00
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
extern "C"
|
|
{
|
|
#include "temps_windows.h"
|
|
}
|
|
#include "util/windows/wmi.hpp"
|
|
|
|
extern "C"
|
|
const char* ffDetectSmbiosTemp(double* current, double* critical)
|
|
{
|
|
// Requires Administrator priviledges
|
|
// 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 "No WMI result returned";
|
|
}
|