none
A Bug in Windows 7 CCD API Sample Code RRS feed

  • Question

  • Hi there,

    I found a minor bug in Windows 7 CCD API samplde code in Windows 7 WDK RC document, here is link to that example.

    Original code:

        UINT32 PathArraySize = 0;
        UINT32 ModeArraySize = 0;
        DISPLAYCONFIG_PATH_INFO* PathArray;
        DISPLAYCONFIG_MODE_INFO* ModeArray;
        DISPLAYCONFIG_PATH_INFO* CurrentPrimary;
        DISPLAYCONFIG_PATH_INFO* NewClonePath;
        DISPLAYCONFIG_TARGET_DEVICE_NAME DeviceName;
        DISPLAYCONFIG_TOPOLOGY_ID TopologyId;
        DISPLAYCONFIG_DEVICE_INFO_HEADER Header;
    
        // Determine the size of the path array that is required to hold all valid paths.
        GetDisplayConfigBufferSizes(1,
                                    &PathArraySize, 
                                    &ModeArraySize);
    
        // Allocate PathArraySize*sizeof(DISPLAYCONFIG_PATH_INFO) 
        // and set PathArray to the allocated memory block.
        // Allocate ModeArraySize*sizeof(DISPLAYCONFIG_MODE_INFO) 
        // and set ModeArray to the allocated memory block.
    
        // Request all of the path information.
        QueryDisplayConfig(1,
                           &PathArraySize, 
                           PathArray, 
                           &ModeArraySize, 
                           ModeArray,
                           &TopologyId);
    
        // Set CurrentPrimary to the current primary path.
    
        // Determine the user friendly name of the current primary.
        Header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME;
        Header.size = sizeof(DISPLAYCONFIG_TARGET_DEVICE_NAME);
        Header.adapterId = CurrentPrimary->targetInfo.adapterId;
        Header.id = CurrentPrimary->targetInfo.id;
        DeviceName.header = Header;
        DisplayConfigGetDeviceInfo(&DeviceName);
    
        // DisplayConfigGetDeviceInfo can determine the user friendly names 
        // for all of the paths that might be part of the clone. 
        // Allow the user to pick which monitor the clone is enabled on.
        // Only provide the user options of the paths from the current primary 
        // to targets with monitors that are connected or that are forceable.  
        // NewClonePath points to the path that the user selected.
    
        // Mark the new path as active.
        NewClonePath->flags |= DISPLAYCONFIG_PATH_ACTIVE;
    
        // Set the new topology.
        SetDisplayConfig(&PathArraySize, 
                         PathArray, 
                         &ModeArraySize, 
                         ModeArray, 
                         SDC_ALLOW_CHANGES);
    According to description of QueryDisplayConfig, when 1st parameter set to 1 (QDC_ALL_PATHS), the latest parameter should be NULL. I confirmed it on my Windows 7 RC box. Call to QueryDisplayConfig in the example code will actually return ERROR_INVALID_PARAMETER.

    It would be nice with correction in next release. Thank you.
    Sam
    Sunday, June 7, 2009 1:32 PM