7

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.

Imbajoe
  • 310
  • 3
  • 16
  • Windows does store a unique ID for each monitor, but it's extremely convoluted to find the ID. Go to Device Manager, expand the Monitors node, right-click and open Properties, and go to the Details tab. Choose *Device Instance Path* from the drop-down list. You'll see something like `\DISPLAY\SomeValue\SomeLongTextWithNumbersLetters&Ampersands` under HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses. (You may find it under ControlSet1 as well.) That's how Windows IDs the monitor, AFAICT. – Ken White Mar 24 '16 at 18:05
  • Unfortunately that doesn't seem to uniquely identify the actual hardware. When I have three plugged in, I get something like this: `- DISPLAY\DELA0CA\4&7053205&0&UID53347072 - DISPLAY\SAM0B94\4&7053205&0&UID51249920 - DISPLAY\DELA0CA\4&7053205&0&UID55444224`. If I removed one of the monitors, I get `- DISPLAY\DELA0CA\4&7053205&0&UID53347072 - DISPLAY\SAM0B94\4&7053205&0&UID51249920`. If I plug that monitor back in, unplug a different monitor, then restart my computer, I still get `- DISPLAY\DELA0CA\4&7053205&0&UID53347072 - DISPLAY\SAM0B94\4&7053205&0&UID51249920` – Imbajoe Mar 25 '16 at 14:42
  • I had issues running 4 24" monitors on a Dell 690 running W7 64 bit. It would boot up running only 2 monitors, until I started doing a 'long' boot, in which BIOS checks all hardware, not knowing if you added ram or changed cpu's, etc. Bios builds a .dmi table (Device master Index) and Windows uses it when it boots up. It now runs all 4 monitors correctly. I know of no way to change this configuration while Windows is running. –  Mar 25 '16 at 23:39

1 Answers1

0

The wmimonitorid class accesses more H/W specific data than EnumDisplaySettings, in particular, the SerialNumberID which should be unique (at the very least) to the entire range of monitors from a specific mfg.
The field is a Uint16 array, so can be read in with code similar to that provided in this answer.

Also try DeviceID in the Win32-PNPEntity class, for PnP monitors. Can be retrieved in a WMI query based on pseudo code like:

SELECT * FROM Win32_PnPEntity WHERE ClassGuid={4d36e96e-e325-11ce-bfc1-08002be10318}
Laurie Stearn
  • 959
  • 1
  • 13
  • 34