Skip to content

Instantly share code, notes, and snippets.

@hecomi
Created December 5, 2018 14:06
Show Gist options
  • Save hecomi/0575c5703c8093338ef16d6834a6e16d to your computer and use it in GitHub Desktop.
Save hecomi/0575c5703c8093338ef16d6834a6e16d to your computer and use it in GitHub Desktop.
GPU とつながってるモニタ調べるヤツ
#include <iostream>
#include <dxgi1_2.h>
#include <wrl/client.h>
#pragma comment(lib, "dxgi.lib")
using namespace Microsoft::WRL;
void OutputGraphicsInformation()
{
ComPtr<IDXGIFactory1> factory;
if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory)))) return;
ComPtr<IDXGIAdapter1> adapter;
for (int i = 0; factory->EnumAdapters1(i, &adapter) != DXGI_ERROR_NOT_FOUND; ++i)
{
DXGI_ADAPTER_DESC desc;
if (FAILED(adapter->GetDesc(&desc))) continue;
std::wcout << "GRAPHICS CARD[" << i << "] : " << desc.Description << std::endl;
ComPtr<IDXGIOutput> output;
for (int j = 0; adapter->EnumOutputs(j, &output) != DXGI_ERROR_NOT_FOUND; ++j)
{
DXGI_OUTPUT_DESC desc;
if (FAILED(output->GetDesc(&desc))) continue;
std::wcout << " > MONITOR[" << j << "] = " << desc.DeviceName << std::endl;
}
}
}
int main()
{
OutputGraphicsInformation();
Sleep(5000);
return 0;
}
GRAPHICS CARD[0] : NVIDIA GeForce GTX 1080
> MONITOR[0] = \\.\DISPLAY1
> MONITOR[1] = \\.\DISPLAY2
GRAPHICS CARD[1] : Microsoft Basic Render Driver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment