I want to get a list of available monitors in Windows 10, same as the monitor list shown in the System display settings (no matter whether they are attached or unattached), just like this:
I use EnumDisplayDevices()
to enumerate all displays, but there is no proper flag indicating whether the display is available.
So, how can I do this?
CodePudding user response:
EnumDisplayDevices
appears to return pseudo-devices too.
According to EnumDisplayMonitors documentation you can use GetSystemMetrics (SM_CMONITORS) to filter out pseudo devices and receive a list of physical devices only.
Potentially a similar question how to list available monitors in c windows 7? helps you too.
CodePudding user response:
EnumDisplayDevices
gives you the DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
and DISPLAY_DEVICE_MIRRORING_DRIVER
flags. MONITORINFOEX
gives you the device name to compare with when mapping from HMONITOR
.