Display Identification

I am trying to define a screen in the setup of several monitors in order to save some data related to this screen. How can I reliably identify the screen, also after rebooting?

I know the class Screenin .Net, but Screen.DeviceNameit doesn’t seem to constantly point to one screen (for example, after installing a new graphics driver).

+5
source share
2 answers

I solved this by getting DeviceID with API EnumDisplayDevices. It seems to be unique for each screen and does not change after updating the driver, for example.

WMI is out of the question since I tried this before and it only returns one monitor with my setup of multiple monitors.

0
source

WMI WinForms.

, (. DisplayDetails  , ):

Edit:

:

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"]);
0

All Articles