T
T
Thandor2015-12-18 01:00:52
C++ / C#
Thandor, 2015-12-18 01:00:52

How to get current screen brightness via winapi?

Code:
HMONITOR hMonitor;
DWORD number=0;
DWORD min=1, max=2, cur=3;
PHYSICAL_MONITOR PhMonitor;
HANDLE hPhMonitor;
BOOL i;
const HWND hDesktop = GetDesktopWindow();
hMonitor = MonitorFromWindow(hDesktop, MONITOR_DEFAULTTOPRIMARY);
GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, &number);
GetPhysicalMonitorsFromHMONITOR(hMonitor, 1, &PhMonitor);
hPhMonitor = PhMonitor.hPhysicalMonitor;
GetMonitorCapabilities(hPhMonitor, &min, &cur);
GetMonitorBrightness(hPhMonitor,&min,&cur,&max);
DestroyPhysicalMonitors(number, &PhMonitor);
GetMonitorBrightness gives ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA, I have win 8.1
Everything works for a friend on win 10.
Is there any other way or possibility to fix this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Spetros, 2015-12-18
@Spetros

Remarks
If this function is supported, the GetMonitorCapabilities function returns the MC_CAPS_BRIGHTNESS flag.
This function takes about 40 milliseconds to return.

https://msdn.microsoft.com/en-us/library/windows/d...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question