-1

I need to be able to read metadata from the monitor, like: gamma, and monitor name, and hopefully, monitor size. Will I have to probe the registry? (SetupAPI???)

I tried DXGI (IDXGIOutput::GetDesc) and WinAPI (EnumDisplayDevicesA).

BROKEN:

HRESULT hr = IDXGIOutput1_GetDesc(output, &monitor_desc);
if(FAILED(hr)) {
    assert(0);
}

printf("monitor name: %s\n", monitor_desc.Description);

ALSO BROKEN:

DISPLAY_DEVICE display_device_desc = { sizeof display_device_desc };
EnumDisplayDevices(NULL, 0, &display_device_desc, 0);
EnumDisplayDevices(display_device_desc.DeviceName,0,&display_device_desc, 0);
printf("monitor name: %s\n", display_device_desc.DeviceString);

I get Generic PnP Monitor instead of the correct name, Hannspree HF225.

Jesse Lactin
  • 301
  • 3
  • 12
  • Note: If you want the (actual, real, physical) monitor dimensions, you should check out this guy's solutions: https://ofekshilon.com/2011/11/13/reading-monitor-physical-dimensions-or-getting-the-edid-the-right-way/ I have implemented his "Setup API" method in my software and it works well. – Adrian Mole Aug 15 '19 at 15:11

1 Answers1

1

1.This EnumDisplayDevices method works.

#include <Windows.h>
#include <iostream>
#include <string>

int main()
{
    DISPLAY_DEVICE dd;
    dd.cb = sizeof(dd);
    int deviceIndex = 0;
    while (EnumDisplayDevices(0, deviceIndex, &dd, 0))
    {
        std::wstring deviceName = dd.DeviceName;
        int monitorIndex = 0;
        while (EnumDisplayDevices(deviceName.c_str(), monitorIndex, &dd, 0))
        {
            std::wcout << dd.DeviceName << L", " << dd.DeviceString << L"\n";
            ++monitorIndex;
        }
        ++deviceIndex;
    }
    return 0;
}
  1. And another WMI method. 3...
Jeffreys
  • 431
  • 2
  • 8