2023-01-09 19:24:19 +08:00
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#include "brightness.h"
|
|
|
|
|
}
|
|
|
|
|
#include "util/windows/wmi.hpp"
|
2023-06-25 14:16:49 +08:00
|
|
|
#include "util/windows/unicode.hpp"
|
2023-01-09 19:24:19 +08:00
|
|
|
|
|
|
|
|
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())
|
|
|
|
|
{
|
2023-06-25 14:16:49 +08:00
|
|
|
if(FFWmiVariant vtValue = record.get(L"CurrentBrightness"))
|
|
|
|
|
{
|
|
|
|
|
FFBrightnessResult* display = (FFBrightnessResult*) ffListAdd(result);
|
|
|
|
|
display->value = vtValue.get<uint8_t>();
|
2023-01-09 19:24:19 +08:00
|
|
|
|
2023-06-25 14:16:49 +08:00
|
|
|
ffStrbufInit(&display->name);
|
|
|
|
|
if (FFWmiVariant vtName = record.get(L"InstanceName"))
|
|
|
|
|
{
|
|
|
|
|
ffStrbufSetWSV(&display->name, vtName.get<std::wstring_view>());
|
|
|
|
|
ffStrbufSubstrAfterFirstC(&display->name, '\\');
|
|
|
|
|
ffStrbufSubstrBeforeFirstC(&display->name, '\\');
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-09 19:24:19 +08:00
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|