none
C++ - GetMonitorBrightness Function COM Error: ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA (0xC0262582)

    Question

  • I am writing a program in Windows and I want to get the brightness of a computer monitor. I am using the Windows GetMonitorBrightness function, however I am having some trouble.

    This is a snippet of my code so far:

    HMONITOR hMonitor = NULL;
    DWORD cPhysicalMonitors;
    LPPHYSICAL_MONITOR pPhysicalMonitors = NULL;
    
    LPDWORD pdwMinimumBrightness=NULL;
    LPDWORD pdwCurrentBrightness=NULL;
    LPDWORD pdwMaximumBrightness=NULL;
    
    HWND hwnd = FindWindow(NULL, NULL);
    
    hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL);
    
    BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, &cPhysicalMonitors);
    pPhysicalMonitors = (LPPHYSICAL_MONITOR)malloc(cPhysicalMonitors* sizeof(PHYSICAL_MONITOR));
    bSuccess = GetPhysicalMonitorsFromHMONITOR(hMonitor, cPhysicalMonitors, pPhysicalMonitors);
    HANDLE pmh = pPhysicalMonitors[0].hPhysicalMonitor; 
    bSuccess = GetMonitorBrightness(pmh, pdwMinimumBrightness, pdwCurrentBrightness, pdwMaximumBrightness);

    I wrote this following the Microsoft documentation.

    But when I run this code I get a COM error: ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA (0xC0262582) - "An error occurred while transmitting data to the device on the I2C bus."

    I have tried searching for solutions to this error but have not been able to find anything related to my situation, it is because of this I ask this question.

    Notes:

    • I am running Windows 7 32-bit
    • My monitor is a CRT monitor (HP 7650 to be exact)
    • The Value of "hPhysicalMonitor" from the "pPhysicalMonitors" array is null (0x00000000) but the value stored in "szPhysicalMonitorDescription" from the "pPhysicalMonitors" array is the correct name of my monitor.

    Please Help.

    p.s. I have also posted this same question to StackOverflow.

    Thursday, January 10, 2013 11:45 AM