0

I want to get each display's information like shown in Windows display settings. I use the following code to get each monitor's info:

int ENUM_CURRENT_SETTINGS = -1;
foreach (Screen screen in Screen.AllScreens)
{
    DEVMODE dm = new DEVMODE();
    dm.dmSize = (short)Marshal.SizeOf(typeof(DEVMODE));
    EnumDisplaySettings(screen.DeviceName, ENUM_CURRENT_SETTINGS, ref dm);
    Console.WriteLine($"Device: {screen.DeviceName}");
    Console.WriteLine($"Real Resolution: {dm.dmPelsWidth}x{dm.dmPelsHeight}");
    Console.WriteLine($"Virtual Resolution: {screen.Bounds.Width}x{screen.Bounds.Height}");
    Console.WriteLine();
}

The result looks like this:

screen infos

But the screen name is not the same as shown in Windows display settings. My Windows display settings looks like this:

Windows display settings

My question is, how can my code get the same info that is shown in Windows display settings?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
WangMeego
  • 1
  • 1
  • Use [WMI](https://learn.microsoft.com/en-us/windows/win32/wmisdk/querying-wmi) can get friendly name like "DELL xxxxx". Refer to [this similar question](https://stackoverflow.com/questions/56844002/getting-the-same-display-names-as-in-advanced-display-settings-panel-with-wina) for more detailed info. – Rita Han Mar 16 '20 at 03:30
  • Does WMI method works for you? – Rita Han Mar 24 '20 at 02:54

0 Answers0