IDXGIFactory::EnumAdapters method (dxgi.h)

Enumerates the adapters (video cards).

Syntax

HRESULT EnumAdapters(
        UINT         Adapter,
  [out] IDXGIAdapter **ppAdapter
);

Parameters

Adapter

Type: UINT

The index of the adapter to enumerate.

[out] ppAdapter

Type: IDXGIAdapter**

The address of a pointer to an IDXGIAdapter interface at the position specified by the Adapter parameter. This parameter must not be NULL.

Return value

Type: HRESULT

Returns S_OK if successful; otherwise, returns DXGI_ERROR_NOT_FOUND if the index is greater than or equal to the number of adapters in the local system, or DXGI_ERROR_INVALID_CALL if ppAdapter parameter is NULL.

Remarks

When you create a factory, the factory enumerates the set of adapters that are available in the system. Therefore, if you change the adapters in a system, you must destroy and recreate the IDXGIFactory object. The number of adapters in a system changes when you add or remove a display card, or dock or undock a laptop.

When the EnumAdapters method succeeds and fills the ppAdapter parameter with the address of the pointer to the adapter interface, EnumAdapters increments the adapter interface's reference count. When you finish using the adapter interface, call the Release method to decrement the reference count before you destroy the pointer.

EnumAdapters first returns the adapter with the output on which the desktop primary is displayed. This adapter corresponds with an index of zero. EnumAdapters next returns other adapters with outputs. EnumAdapters finally returns adapters without outputs.

Examples

Enumerating Adapters

The following code example demonstrates how to enumerate adapters using the EnumAdapters method.


UINT i = 0; 
IDXGIAdapter * pAdapter; 
std::vector <IDXGIAdapter*> vAdapters; 
while(pFactory->EnumAdapters(i, &pAdapter) != DXGI_ERROR_NOT_FOUND) 
{ 
	vAdapters.push_back(pAdapter); 
	++i; 
} 

Requirements

Requirement Value
Target Platform Windows
Header dxgi.h
Library DXGI.lib

See also

DXGI Interfaces

IDXGIFactory