0
votes

I've got a call like this:

while(EnumDisplayDevices(NULL, index, &displayDevice, 0)) {
  // do stuff
}

My understanding is that this is supposed to report all graphics devices as displayDevice but it only reports one, multiple times. I've got an Intel card as my primary adapter and and NVidia card as secondary -- I'm hoping to be able to not only get the names and info of both cards but also to determine which the app is run with (ie the app defaults to the Intel but I can change the default in the NVidia control panel or even with the context menu in Windows Explorer). However, the call always reports three devices... and all three are the Intel. It reports Intel as \.\DISPLAY1, \.\DISPLAY2 and \.\DISPLAY3.

I can confirm that my code runs with the correct graphics card by looking at the DLLs that it uses. (Indeed, I needed to connect a second monitor to get it to use the NVidia card at all -- otherwise, the app would launch on the Intel no matter what card I chose. Either way, the Intel card always comes back as DISPLAY_DEVICE_ACTIVE.

1
Have you tried the DxCapsViewer from the Windows 8.x SDK or the legacy DirectX SDK? EnumDisplayDevices is an old-school API so you may have better luck using DXGI (Windows Vista or later) or Direct3D 9 (Windows XP). - Chuck Walbourn
I was hoping that wasn't it. But I'm not very surprised to hear that its an old API that has just been allowed to go stale. - Dave

1 Answers

0
votes

This is because flag in DISPLAY_DEVICE structure, DISPLAY_DEVICE_PRIMARY_DEVICE --The primary desktop is on the device. For a system with a single display card, this is always set. For a system with multiple display cards, only one device can have this set. To fetch active display devices from second GPU use following flag condition

    while (EnumDisplayDevices(NULL, index, &dd, 0))
    {
        if(((dd.StateFlags & DISPLAY_DEVICE_ACTIVE) && ((dd.StateFlags & DISPLAY_DEVICE_ACTIVE) || (!(dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE))) &&(!(dd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER))))
        {
            activeDispCount++;
        }
        index++;
    }