来自 D3D 显示适配器 ID 的描述性监视器名称 [英] Descriptive monitor name from D3D display adapter ID

查看:26
本文介绍了来自 D3D 显示适配器 ID 的描述性监视器名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

As the question suggests, I'm trying to pull a descriptive monitor name to match with a display adapter name. The code below gives me a device ID like \.\DISPLAY1 which is understandable but not what I'm looking for.

    // 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?

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

I've looked around the documentation for where to pull that actual name from but until now I haven't been able to find it. Sometimes I am a little stupid (or blind if you will), so I'll give it another go during my lunch break -- but perhaps someone can point me in the right direction? Thanks a lot.

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

(and by actual name I mean the one presented in the graphics configuration panel)

推荐答案

    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();
}

这篇关于来自 D3D 显示适配器 ID 的描述性监视器名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆