diff --git a/CMakeLists.txt b/CMakeLists.txt index 03763387c..32b57debb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -463,7 +463,7 @@ elseif(WIN32) src/detection/battery/battery_windows.c src/detection/bios/bios_windows.c src/detection/board/board_windows.c - src/detection/brightness/brightness_nosupport.c + src/detection/brightness/brightness_windows.cpp src/detection/chassis/chassis_nosupport.c src/detection/cpu/cpu_windows.c src/detection/cpuUsage/cpuUsage_windows.c diff --git a/src/detection/brightness/brightness_windows.cpp b/src/detection/brightness/brightness_windows.cpp new file mode 100644 index 000000000..3139fef4c --- /dev/null +++ b/src/detection/brightness/brightness_windows.cpp @@ -0,0 +1,27 @@ +extern "C" +{ +#include "brightness.h" +} +#include "util/windows/wmi.hpp" + +extern "C" +const char* ffDetectBrightness(FFlist* result) +{ + FFWmiQuery query(L"SELECT CurrentBrightness, InstanceName FROM WmiMonitorBrightness WHERE Active = true", nullptr, FFWmiNamespace::WMI); + if(!query) + return "Query WMI service failed"; + + while(FFWmiRecord record = query.next()) + { + FFBrightnessResult* display = (FFBrightnessResult*) ffListAdd(result); + ffStrbufInit(&display->name); + record.getString(L"InstanceName", &display->name); + ffStrbufSubstrAfterFirstC(&display->name, '\\'); + ffStrbufSubstrBeforeFirstC(&display->name, '\\'); + + uint64_t brightness; + record.getUnsigned(L"CurrentBrightness", &brightness); + display->value = (float) brightness; + } + return NULL; +}