views:

306

answers:

1

I am trying to enumerate all the monitors in Windows 7, and according to MSDN, using the QueryDisplayConfig method is the correct way to do this. All of this code works fine, and returns a couple of arrays, one with paths and one with modes. However, it doesn't have the same monitor ID's as Windows. I am trying to build an array of all the monitors that appear in the Windows 7 "Screen Resolution" dialog. The paths collection return far too many items, and I'm not sure how to tell if it's a valid non-active monitor. Any help would be much appreciated.

UINT32 PathArraySize = 0;
UINT32 ModeArraySize = 0;
DISPLAYCONFIG_PATH_INFO* PathArray;
DISPLAYCONFIG_MODE_INFO* ModeArray;

GetDisplayConfigBufferSizes(
    QDC_ALL_PATHS, &PathArraySize, &ModeArraySize);
PathArray = (DISPLAYCONFIG_PATH_INFO*)malloc(
    PathArraySize * sizeof(DISPLAYCONFIG_PATH_INFO));
memset(PathArray, 0, PathArraySize * sizeof(DISPLAYCONFIG_PATH_INFO));

ModeArray = (DISPLAYCONFIG_MODE_INFO*)malloc(
    ModeArraySize * sizeof(DISPLAYCONFIG_MODE_INFO));
memset(ModeArray, 0, ModeArraySize * sizeof(DISPLAYCONFIG_MODE_INFO));

LONG rtn = QueryDisplayConfig(
    QDC_ALL_PATHS, &PathArraySize, PathArray, &ModeArraySize, ModeArray, NULL);

alt text

A: 

Hi,

I ve tried using the same code, but am not able to use any of the CCD APIs. I have included windows.h and user32.lib in my proj. I have copied user32.lib in the project folder itself, so there shouldn't be any prob with path location. When I see the functions in the dll, am seeing all the CCD APIs, but am not seeing them in my proj.

If I try accessing the DLL directly using LoadLibrary and GetProcAddress, am getting "Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call". Though some ppl say this is because of change in the type of function call (either __cdecl or __stdcall) than that during compilation (either __stdcall or __cdecl), I am not able to figure out how to check whether this function is getting called using __cdecl or __stdcall. The dll is compiled using __cdecl itself.

Am using Visual C++6.0 to implement this function. Could someone provide solution for my prob plz.

Regards, Vivek.

Vivek