c++ - 来自 D3D 显示适配器 ID 的描述性监视器名称

标签 c++ windows direct3d9

正如问题所暗示的,我试图提取一个描述性的监视器名称以匹配显示适配器名称。下面的代码给了我一个像\.\DISPLAY1 这样的设备 ID,这是可以理解的,但不是我要找的。

    // Get name.
    D3DADAPTER_IDENTIFIER9 d3dID;
    d3d9.Get().GetAdapterIdentifier(iAdapter, 0, &d3dID);   
    dispAd.name = d3dID.Description;

    // Add monitor ID to display adapter name.
    FIX_ME // Not happy with this yet!
    HMONITOR hMonitor = d3d9.Get().GetAdapterMonitor(iAdapter);
    MONITORINFOEXA monInfoEx;
    monInfoEx.cbSize = sizeof(MONITORINFOEXA);
    if (GetMonitorInfoA(hMonitor, &monInfoEx))
    {
        dispAd.name = dispAd.name + " on: " + monInfoEx.szDevice;
    }
    else TPB_ASSERT(0); // Mute?

我查看了文档以了解从何处提取该实际名称,但直到现在我还没有找到它。有时我有点愚蠢(如果你愿意的话,也可以说是盲目的),所以我会在午休时间再试一次——但也许有人能给我指出正确的方向?非常感谢。

(我指的是图形配置面板中显示的实际名称)

最佳答案

    UINT iOutput = 0;
IDXGIOutput *pOutput = nullptr;
while (DXGI_ERROR_NOT_FOUND != pAdapter->EnumOutputs(iOutput++, &pOutput))
{
    DXGI_OUTPUT_DESC desc;
    VERIFY(S_OK == pOutput->GetDesc(&desc));

    MONITORINFOEXW monInfoEx;
    monInfoEx.cbSize = sizeof(MONITORINFOEXW);
    GetMonitorInfoW(desc.Monitor, &monInfoEx);

    DISPLAY_DEVICEW dispDev;
    dispDev.cb = sizeof(DISPLAY_DEVICEW);
    EnumDisplayDevicesW(monInfoEx.szDevice, 0, &dispDev, 0);

    // FIXME: far from perfect, but should do the job if a vendor driver is installed.
    //        Otherwise it just displays something along the lines of "Plug & Play monitor".
    SendDlgItemMessageW(hDialog, IDC_COMBO_OUTPUT, CB_ADDSTRING, 0, (LPARAM) dispDev.DeviceString);

    pOutput->Release();
}

关于c++ - 来自 D3D 显示适配器 ID 的描述性监视器名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6834156/

相关文章:

c++ - 使用 Clang 编译 DLL 时指定 DEF 文件

windows - Assetic 在 Windows 上生成空文件(symfony2 + less)

windows - IPv4 属性 UI 中与 "Use the following IP Address"等效的 Powershell 是什么?

c++ - Direct3D9 游戏 : Spaceship camera

c++ - 将相机旋转到模型的中心

directx - (DirectX 9) 隐式应用 Gamma 校正

c# - C++ 等同于 C# OOP if(Boy b is Student)

c++ - 模板类中的静态函数

c++ - 如何在此代码中正确使用 strcmp() ?

windows - 如何区分 Windows 权限