1
votes

I have have found out a monitors' device name by inspecting the value DEV_BROADCAST_DEVICEINTERFACE.dbcc_name and I am attempting to use that device name inside the function EnumDisplaySettings() (the device name is the first parameter of that function).

My Problem: The function EnumDisplaySettings() always returns 0, ie, fails. I believe it fails because MSDN says the first parameter of EnumDisplaySettings() should be a DISPLAY_DEVICE.DeviceName returned from EnumDisplayDevices whereas my device name is from DEV_BROADCAST_DEVICEINTERFACE.dbcc_name.

Using DEV_BROADCAST_DEVICEINTERFACE.dbcc_name I get the device name \\?\DISPLAY#GSM3AD7#5&20a3f50d&0&UID513#{866519b5-3f07-4c97-b7df-24 c5d8a8ccb8} for my second monitor whereas EnumDisplayDevices() gives me the device name \\.\DISPLAYV1.

Is it possible to use EnumDisplaySettings() where the 1st parameter is a device name retrieved from the function DEV_BROADCAST_DEVICEINTERFACE.dbcc_name?

The reason why I ask is: when a second monitor gets connected to the computer I want to change that monitors display settings. But upon monitor connection I am notified of its device name through DEV_BROADCAST_DEVICEINTERFACE.dbcc_name which (as I explained above) is a different name to what EnumDisplayDevices() returns for the exact same device. And I dont know how I could identify that second monitor by enumerating though all display devices using EnumDisplayDevices()? Any ideas how I could enumerate though all display devices using EnumDisplayDevices() and identify the correct monitor/device that was just connected to the computer?

2

2 Answers

1
votes

I can't guarantee it, but I'd guess that a display device retains its name as long as it remains connected.

On that assumption, I'd run EnumDisplayDevices when your program starts. When the new monitor is connected, use EnumDisplayDevices again, and compare the list of devices to your previous list, then EnumDisplaySettings on whichever device was newly added to the list.

When you're done with that, replace the old list with the new list, and you're ready for the next time the user plugs in another monitor.

0
votes

Have a look at these previous answers for clues to help you turn a DEV_BROADCAST_DEVICEINTERFACE.dbcc_name value into a suitable DISPLAY_DEVICE.DeviceName value:

acessing dbcc_name from DEV_BROADCAST_DEVICEINTERFACE win32 programming

How to get friendly device name from DEV_BROADCAST_DEVICEINTERFACE and Device Instance ID