locked
Getting Monitor Names RRS feed

  • Question

  • I am trying to get the monitor and video card names for the local system, and I can't seem to do it.

    Screen.PrimaryScreen.DeviceName just returns something like "\\.\DEVICE1".  What can I do with that?  When I query WMI I get some results:
    ManagementObjectSearcher("root\\CIMV2", "SELECT DeviceID, Description FROM Win32_DesktopMonitor")

    But how do I know wihch Screen and/or video card this belongs to?
    Wednesday, February 6, 2008 7:10 PM

Answers

  • I am not sure exactly what you mean by monitor name, the unique monitor name?  If when you callEnumDisplayDevices to enumerate the monitor you can specify the following flag: EDD_GET_DEVICE_INTERFACE_NAME then in the DeviceID field of the DISPLAY_DEVICE structure you will see the unique monitor name.

     

    What scenario are you trying to solve?

    Monday, February 11, 2008 2:57 AM
  • Thanks, your solution was almost 100% there.  The only thing I needed to add was a second call to EnumDisplayDevices and passing in the DeviceName returned from the first call.  Then the DeviceName is populated with the Monitor's name and not the Video card.  Perfect!

    Thanks,
    Jon
    Monday, February 11, 2008 3:26 AM

All replies

  • Why not cheat a little bit?  Look these up in the object browser.

     

    public Computer()

    Member of Microsoft.VisualBasic.Devices.Computer

    Summary:

    Initializes a new instance of the Microsoft.VisualBasic.Devices.Computer class.

     

    public System.Windows.Forms.Screen Screen { get; }

    Member of Microsoft.VisualBasic.Devices.Computer

    Summary:

    Gets the System.Windows.Forms.Screen object that represents the computer's primary display screen.

    Returns:

    A System.Windows.Forms.Screen object that represents the computer's primary screen.

     

    public class Screen

    Member of System.Windows.Forms

    Summary:

    Represents a display device or multiple display devices on a single system.

     

    public static System.Windows.Forms.Screen[] AllScreens { get; }

    Member of System.Windows.Forms.Screen

    Summary:

    Gets an array of all displays on the system.

    Returns:

    An array of type System.Windows.Forms.Screen, containing all displays on the system.

     

    Rudedog

    Wednesday, February 6, 2008 7:25 PM
  • This is one of the methods that I have already tried, but the "devicename" is always something useless like "\\.\DEVICE1".  What I need to get is the actual monitor name, like "BenQ FP54".
    Wednesday, February 6, 2008 7:28 PM
  • Yikes.  Do you think the info is available from the device drivers?

     

    Wednesday, February 6, 2008 7:32 PM
  • I'm still having this problem - does anyone else have any ideas?

    Thanks,
    Jon
    Sunday, February 10, 2008 4:47 PM
  • Hi Jon,

      in order to get the monitor names you will have to call EnumDisplayDevices via PInvoke.  You ned to pas in the device name you got from Screen.PrimaryScreen.Device name into this function and then you can iterate through all of the monitors that are connected.

     

    If you lok at the msdn page for this method: http://msdn2.microsoft.com/en-us/library/ms533226.aspx and the www.pinvoke.net pages: http://www.pinvoke.net/default.aspx/user32/EnumDisplayDevices.html This should be enough information for you.

     

    Mark.

    Sunday, February 10, 2008 6:42 PM
  • Hi Mark,
    I have tried these, and they work well for enumerating the displays and getting the display names, but none of these can get the monitor's name.  I can't believe there is no documented way to find out which video card a monitor is connected to.  I have looked everywhere and I can't find anything.

    Jon
    Monday, February 11, 2008 1:48 AM
  • I am not sure exactly what you mean by monitor name, the unique monitor name?  If when you callEnumDisplayDevices to enumerate the monitor you can specify the following flag: EDD_GET_DEVICE_INTERFACE_NAME then in the DeviceID field of the DISPLAY_DEVICE structure you will see the unique monitor name.

     

    What scenario are you trying to solve?

    Monday, February 11, 2008 2:57 AM
  • Thanks, your solution was almost 100% there.  The only thing I needed to add was a second call to EnumDisplayDevices and passing in the DeviceName returned from the first call.  Then the DeviceName is populated with the Monitor's name and not the Video card.  Perfect!

    Thanks,
    Jon
    Monday, February 11, 2008 3:26 AM
  • Hi - glad to hear you got the answer, I have used these APIs quite a bit and they are a little bit painful to use.

     

    Mark.

    Monday, February 11, 2008 3:30 AM
  • Hi I could also help get the name of the monitor with vb.net but I failed to get the focus could be how to achieve this some reference?

    Thanks

    this is my email if you can help francrv@hotmail.com
    Wednesday, December 30, 2009 5:06 PM