Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Is it possible to reduce the "Backlight brightness" in Windows Embedded standard 7, Monitor:Samsung DE40A programmatically with vc++ ? It is possible to reduce monitor backlight brightness with the monitor's remote.
I have been able to reduce brightness,contrast,gamma, and RGB values with the respective APIs SetMonitorBrightness, SetMonitorContrast, etc. Tried to use DeviceIoControl function with IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS but the function call doesn't succeed, it gives a non-zero value and according to msdn the function has failed

C++
//Get the handle
HANDLE hLCD = CreateFile("\\\\.\\LCD",       // open LCD device
                         GENERIC_READ,                  // access to the drive
                         FILE_SHARE_READ|FILE_SHARE_WRITE,// share mode
                         NULL,                          // default security attributes
                         OPEN_EXISTING,                 // disposition
                         0,                             // file attributes
                         NULL);

if (hLCD == INVALID_HANDLE_VALUE)
{
    cout << "error: Invalid Handle, unable to get LCD handle" << GetLastError() << endl;
    return 1;
}

BYTE SupportedBrightness[256];
DWORD nBytesReturned;

int nRes = DeviceIoControl(
               (HANDLE) hLCD,                           // handle to device
               IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS,  // dwIoControlCode
               NULL,                                    // lpInBuffer
               0,                                       // nInBufferSize
               (LPVOID) SupportedBrightness,            // output buffer
               sizeof(SupportedBrightness),             // size of output buffer
               (LPDWORD) &nBytesReturned,               // bytes returned
               NULL                                     // OVERLAPPED
           );

if (nRes == 0)
{
    cout << "error: Backlight Not Supported" << GetLastError() << endl;
    return 2;
}

cout << "Supported levels:: ";
for (DWORD i=0; i<nBytesReturned; i++)
{
    cout << (DWORD)SupportedBrightness[i] << ", ";
}
cout << endl << endl;







I end up getting "Backlight not supported", but I can change back light brightness from Samsung Monitor's remote.
Please suggest any known method to reduce back-light brightness programmatically.
Posted
Comments
Jochen Arndt 4-Feb-16 3:15am    
What is the error code? The function may also fail when passing wrong parameters.
Member 11805384 4-Feb-16 7:22am    
The error code it returned was "4". Invalid handle!.
Is there any other method to reduce backlight brightness ?
Jochen Arndt 4-Feb-16 7:43am    
ERROR_INVALID_HANDLE has value 6.
Value 4 is ERROR_TOO_MANY_OPEN_FILES.

If the function is not supported, I would expect a different error code. But using IOCTL for monitors is deprecated and might be the reason for the failure.

You may use WMI (Windows Management Instrumentation) instead. See https://msdn.microsoft.com/en-us/library/windows/desktop/aa394536%28v=vs.85%29.aspx.
Member 11805384 4-Feb-16 8:39am    
Sorry, yes it's "6".
I'm using IOCTL because https://msdn.microsoft.com/en-us/library/windows/desktop/aa372703%28v=vs.85%29.aspx says that it gives the supported "BACK LIGHT" brightness levels, where as WMI doesn't give any info about backlight brightness specifically.
Jochen Arndt 4-Feb-16 9:13am    
See my WMI link. It provides Level (the array of values) and Levels (the number of items).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900