4

For my project I need a way to get data regarding screens that are connected. In specific, I need to identify whether a monitor is a laptop internal screen or an external screen, and get all the screen data.

I need to get this information both in c++ and C#.

I read about Win32_DesktopMonitor, about EnumDisplayDevices and about Screen Class. I read also some related questions here: Monitor ID and Serial Number Find Number and resolution to all monitors EnumDisplayDevices vs WMI Win32_DesktopMonitor, how to detect active monitors?

I havn't found an answer yet. Any Ideas?

Community
  • 1
  • 1
eskadi
  • 245
  • 3
  • 17
  • 1
    @GrantWinney if you look into the links he provided, those links will give you an enormus amount of information about the screen, but not whether it is an internal or external screen, so he did research, but could not find an answer. – SynerCoder May 20 '14 at 13:30
  • 2
    Windows operating system doesn't care if a monitor is internal verses external. If your application needs to display something on an external monitor, the program should give the user a choice and ask them which monitor is external. – Black Frog May 20 '14 at 13:32
  • Looking over the links in your question I came across [Screen.PrimaryScreen Property](http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.primaryscreen.aspx). I believe that should lead you in the right direction. I has an example of making a Windows Forms fill the primary screen. Then everything else should be on the other monitor. – Black Frog May 20 '14 at 13:39
  • Thanks for your comments. The thing is, going over all the screens gives me information, but I could't find from that information whether the monitor is internal or external and this is the information I am looking for. – eskadi May 21 '14 at 13:09

2 Answers2

0

To get the information whether monitor is internal you can use WMI class WmiMonitorConnectionParams from root\wmi namespace.

Code would need to create a CimSession by connecting to WMI either through DCOM or WinRM (with authentication as needed if enumerating remote computer monitors), then call EnumerateInstances(@"root\wmi", "WmiMonitorConnectionParams") on that session.

Resulting collection will contain InstanceName (string) and VideoOutputTechnology (UInt32).

You will need both for each monitor so you can match them with the other stuff you need.

If VideoOutputTechnology is 0xFFFFFFFF, then that's the Default Monitor entry and it can be ignored. If it is 0x80000000, then it is internal. Other types of connection are documented in d3dkmdt.h header file (online documentation at the moment of this writing does not provide correct values for the enum).

The most reliable way to get model, serial number, as well as year and week of manufacture is by reading and parsing the raw EDID block (by calling WmiGetMonitorRawEEdidV1Block).

I hope you can get by on your own from here.

Igor Levicki
  • 1,017
  • 10
  • 17
  • While this is probably what he needs, it is so brittle (what's to stop a manufacturer to not use `0x80000000`?) that it makes me wonder what could he possibly use this for. – Blindy Jul 15 '22 at 15:22
  • @Blindy It is not brittle at all. Video driver may mistakenly detect HDMI connected monitor as a TV, but it cannot mistake it for internal even if EDID reports wrong information. The reason why someone would need to detect whether display is internal is for example performing a remote inventory of your IT assets -- you would want to create entries just for attached monitors, not for the builti-in laptop display, because that one is the part of the laptop itself. – Igor Levicki Jul 16 '22 at 14:14
-3

What you can do is query the Windows WMI classes:

http://msdn.microsoft.com/en-us/library/aa394554(v=vs.85).aspx

Those classes allows the user to collect various information about the computer (hardware, os, ...)

I don't know if you'll find the properties you need, but it might be worth a look. You're looking for this class:

http://msdn.microsoft.com/en-us/library/aa394122(v=vs.85).aspx

Complexity
  • 5,682
  • 6
  • 41
  • 84