5

I am trying to identify a screen in a multi-monitor setup to save some data linked to that screen. How can I reliable identify a screen, also after a reboot?

I am aware of the Screen class in .Net but Screen.DeviceName seems not be consistently pointing to one screen (for example after installing a new graphics driver).

GETah
  • 20,922
  • 7
  • 61
  • 103
Jelle Vergeer
  • 1,018
  • 1
  • 17
  • 35
  • Do you really expect to be able to change your device drivers and still keep track of a certain screen? The real question is, why would you want to do that? – Kendall Frey May 19 '12 at 21:42
  • Well, because I am writing a little multi-monitor tool and need to save settings for each screen. – Jelle Vergeer May 19 '12 at 21:50

2 Answers2

0

Try WMI instead of WinForms.

The following post shows how to get monitors and their details (s. DisplayDetails class e.g.): Monitor ID and Serial Number

Edit:

My suggestion:

using System.Management;

ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_DesktopMonitor");     
foreach (ManagementObject obj in searcher.Get())
    Console.WriteLine("PNP Device ID: {0}", obj ["PNPDeviceID"]);
Community
  • 1
  • 1
0

I solved this by getting the DeviceID with the EnumDisplayDevices API. Seems to be unique for each screen and does not change after a driver update for example.

WMI is out of the question for me as I tried it before and it only returns one monitor with my multi-monitor setup.

Jelle Vergeer
  • 1,018
  • 1
  • 17
  • 35