#include#include int main() { IDXGIFactory* factory; CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory); std::vector adapters; IDXGIAdapter* adapter; for (UINT i = 0; factory->EnumAdapters(i, &adapter) != DXGI_ERROR_NOT_FOUND; i++) adapters.push_back(adapter); factory->Release(); // Use adapters... }
#includeThis code example shows how to query adapter properties using the IDXGIAdapter interface's GetDesc method. The method returns a structure containing various adapter properties, such as the adapter's name, vendor id, device id, and other information. The example shows how to extract the adapter name from the structure and convert it to a string using a string stream. Package Library: DirectX SDK.#include #include std::string GetAdapterName(IDXGIAdapter* adapter) { DXGI_ADAPTER_DESC desc; adapter->GetDesc(&desc); std::ostringstream ss; ss << desc.Description; return ss.str(); } int main() { IDXGIFactory* factory; CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory); IDXGIAdapter* adapter; factory->EnumAdapters(0, &adapter); std::string adapterName = GetAdapterName(adapter); factory->Release(); adapter->Release(); // Use adapterName... }