I am trying to write a program for re-configuring displays in the cases where a display loses connection, and Windows is not able to correctly reconfigure its prior settings.
Usually if you unplug a monitor, Windows seems to keep track of configuration settings for the display. Example, I have three monitors hooked up right now. If I unplug my "main display", Windows will make one of the remaining two monitors the main display. Then if I reconnect the monitor, Windows will usually remember the configuration for that monitor, specifically in this case that it was my main display, and set it appropriately.
I am currently using EnumDisplayDevices
, EnumDisplaySettings
, and ChangeDisplaySettingsEx
to set the configurations for each monitor (resolution, orientation, etc). However, looking at what information EnumDisplayDevices
and EnumDisplaySettings
populate the DISPLAY_DEVICE
and DEVMODE
structs with, nothing seems to be able to uniquely identify the monitors themselves. I'll get values that will uniquely identify each display from each other for the current configuration (\.\DISPLAY1 and \.\DISPLAY2 \.\DISPLAY3, for example), but if I unplug the monitor that had the identifier \.\DISPLAY1, next time running I'll get the values \.\DISPLAY1 and \.\DISPLAY2. So that value can't be used to unqiuely identify a specific monitor later on.
Is there some piece of unique information about each monitor hooked up that I can use to identify them? My feeling that such a piece of information might exist comes from the fact that most of the time if I unplug a monitor and plug it back in, Windows will retain its configuration.