CCD API SetDisplayConfig returns ERROR_INVALID_PARAMETER

Hi,

I am currently trying to use SetDisplayConfig to configure displays. I am
not using User32.lib to access the User32.dll rather using GetProcAddress.

The functions “GetDisplayConfigBufferSizes” and “QueryDisplayConfig” works
fine. But “SetDisplayConfig” returns “invalid parameter”.

I am adding my code here.

LONG returnValue = 0;
UINT32 *pNumPathArrayElements = new UINT32();
UINT32 *pNumModeInfoArrayElements = new UINT32();
UINT32 NumPathArrayElements = 0;
UINT32 NumModeInfoArrayElements = 0;

returnValue = GetDisplayConfigBufferSizes(
QDC_ALL_PATHS, pNumPathArrayElements, pNumModeInfoArrayElements); // Returns
Success
returnValue = QueryDisplayConfig(QDC_ALL_PATHS, pNumPathArrayElements,
pPathInfoArray, pNumModeInfoArrayElements, pModeInfoArray, NULL); // Returns
Success

DISPLAYCONFIG_PATH_INFO *pPathInfoArray = new
DISPLAYCONFIG_PATH_INFO[*pNumPathArrayElements];
DISPLAYCONFIG_MODE_INFO *pModeInfoArray = new
DISPLAYCONFIG_MODE_INFO[*pNumModeInfoArrayElements];

NumPathArrayElements = *pNumPathArrayElements;
NumModeInfoArrayElements = *pNumModeInfoArrayElements;

Set appropriate flags and variables according to the expectations here.

* Am currently enabling the flag value as DISPLAYCONFIG_PATH_ACTIVE
for the variable in the array DISPLAYCONFIG_PATH_INFO *pPathInfoArray on
which the display should be enabled, and all other flag values to zero. I
also tried passing a single variable for the path parameter and a single
variable for the mode parameter rather than passing the entire arrays to
SetDisplayConfig.*

returnValue = SetDisplayConfig(NumPathArrayElements, pPathInfoArray,
NumModeInfoArrayElements, pModeInfoArray, SDC_APPLY | SDC_SAVE_TO_DATABASE |
SDC_ALLOW_CHANGES); // Returns Invalid Parameter

Does anyone know what the problem might be? Am I missing something important
before calling SetDisplayConfig?

Am stuck with this issue for more than a month now. Can anyone please
provide pointers on resolving the issue or maybe the exact way of using
SetDisplayConfig (if am using it wrong here).

*Test Configuration:*

OS Used: Microsoft Windows 7 Enterprise
Displays Connected: CRT, LFP (LVDS).
Intel(R) Core™ Duo CPU T9550 @ 2.66GHz, 2667 Mhz, 2 Core(s), 2 Logical
Processor(s)

OS Used: Microsoft Windows 7 Ultimate
Display(s) Connected: CRT, LFP (LVDS/eDP), DP, HDMI.
Intel(R) Core™ i5 Processor

*Note:* I was unable to access the CCD APIs in User32.dll using User32.lib,
so i created my own data structures (copied the ones required from WinUser.h
and WinGDI.h) and tried accessing the CCD APIs in User32.dll using *
LoadLibrary* and *GetProcAddress *for configuring displays.

Thanks in advance.

Regards,
Vivekanand Ilango (Vivek),
Graphics Software Engineer,
Intel Technology India Pvt. Ltd.,
+91 7760504553.