How To: Enumerate Adapters

This topic shows how to use Microsoft DirectX Graphics Infrastructure (DXGI) to enumerate the available graphics adapters on a computer. Direct3D 10 and 11 can use DXGI to enumerate adapters.

You generally need to enumerate adapters for these reasons:

  • To determine how many graphics adapters are installed on a computer.
  • To help you choose which adapter to use to create a Direct3D device.
  • To retrieve an IDXGIAdapter object that you can use to retrieve device capabilities.

To enumerate adapters

  1. Create an IDXGIFactory object by calling the CreateDXGIFactory function. The following code example demonstrates how to initialize an IDXGIFactory object.

    IDXGIFactory * pFactory = NULL;
    CreateDXGIFactory(__uuidof(IDXGIFactory) ,(void**)&pFactory)
  2. Enumerate through each adapter by calling the IDXGIFactory::EnumAdapters method. The Adapter parameter allows you to specify a zero-based index number of the adapter to enumerate. If no adapter is available at the specified index, the method returns DXGI_ERROR_NOT_FOUND.

    The following code example demonstrates how to enumerate through the adapters on a computer.

    for (UINT i = 0; 
         pFactory->EnumAdapters(i, &pAdapter) != DXGI_ERROR_NOT_FOUND; 
    { ... }

The following code example demonstrates how to enumerate all adapters on a computer.


For Direct3D 11.0 and later, we recommend that apps always use IDXGIFactory1 and CreateDXGIFactory1 instead.


std::vector <IDXGIAdapter*> EnumerateAdapters(void)
    IDXGIAdapter * pAdapter; 
    std::vector <IDXGIAdapter*> vAdapters; 
    IDXGIFactory* pFactory = NULL; 

    // Create a DXGIFactory object.
    if(FAILED(CreateDXGIFactory(__uuidof(IDXGIFactory) ,(void**)&pFactory)))
        return vAdapters;

    for ( UINT i = 0;
          pFactory->EnumAdapters(i, &pAdapter) != DXGI_ERROR_NOT_FOUND;
          ++i )


    return vAdapters;


How to Use Direct3D 11