7

Is there anyway using WMI/.Net to grab monitor information such as Manufacturer, Serial Number, Monitor Size etc.?

Using a script is an option as well, or can I query the registry directly to get this information?

SELECT * FROM Win32_DesktopMonitor doesn't really return any useful information for me in this case.

mint
  • 3,341
  • 11
  • 38
  • 55

4 Answers4

12

Hey, I use this tool for a lot of my WMI work, especially when prototyping and creating POCs....

Microsoft WMI Code Generator

This tool is great for creating quick console app code for any wmi query or method invocation in both C# and VB.NET

try
        {
            ManagementObjectSearcher searcher = 
                new ManagementObjectSearcher("root\\CIMV2", 
                "SELECT * FROM Win32_DesktopMonitor"); 

            foreach (ManagementObject queryObj in searcher.Get())
            {
                Console.WriteLine("-----------------------------------");
                Console.WriteLine("Win32_DesktopMonitor instance");
                Console.WriteLine("-----------------------------------");
                Console.WriteLine("Description: {0}", queryObj["Description"]);
            }
        }
        catch (ManagementException e)
        {
            MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
        }

The code above will get you the make and model of the monitor.

Roooss
  • 626
  • 1
  • 9
  • 24
  • 1
    FYI, Win32_DesktopMonitor doesn't appear to get all monitors. WMIMonitorID, from root\WMI, appears to get more/all. – Tydaeus May 23 '18 at 21:15
6

You may want to try this

https://raw.githubusercontent.com/MaxAnderson95/Get-Monitor-Information/master/Get-Monitor.ps1

Cheers

Iain
  • 6,392
  • 2
  • 30
  • 50
2

That select query should give you what you want. Here is the documentation which contains the details of the query.

Then you could do something like this:

    public void GetMonitorDetails()
    {
       using(ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DesktopMonitor")
       {
          foreach(ManagementObject currentObj in searcher.Get())
          {
             String name = currentObj("Name").ToString();
             String device_id = currentObj("DeviceID").ToString();
             // ...
          }
       }
    }
SwDevMan81
  • 48,814
  • 22
  • 151
  • 184
  • That's the query I listed in the question that doesn't work :)! – mint Aug 13 '10 at 13:23
  • It doesn't give me a lot of the information I'm looking for (Serial #, Monitor Size, It says Monitor Manufacturer but it's value is : which isn't what I was looking for. – mint Aug 13 '10 at 13:31
  • @snow : That could be due to the currently installed monitor you have on your machine... Have a look in device manager to see what the details on your currently installed monitor and compare. – Xander Aug 13 '10 at 14:47
  • Win32_DesktopMonitor doesn't list all the monitors that are connection. Currently I have 10 monitors connected and running properly to my PC but this query lists only 4 of them. – Roni Tovi Sep 17 '15 at 11:26
  • @RoniTovi 10 monitors ? – Kiquenet Apr 29 '19 at 15:07
  • @Kiquenet Yes, it was a videowall application using only 1 pc. – Roni Tovi May 07 '19 at 23:10
  • How connected 10 monitors to motherboard? using DVI, HDMI, VGA ? – Kiquenet May 08 '19 at 07:10
0

This post, combined with the answer below about the WMI management tool had my answer. Here is the code that returns your monitor resolutions.

try {                 
        ManagementObjectSearcher searcher =
            new ManagementObjectSearcher("root\\WMI",
            "SELECT * FROM WmiMonitorBasicDisplayParams");    

        foreach (ManagementObject queryObj in searcher.Get()) {
            Debug.WriteLine("-----------------------------------");
            Debug.WriteLine("WmiMonitorBasicDisplayParams instance");
            Debug.WriteLine("-----------------------------------");
            Debug.WriteLine("Description: {0}", queryObj["SupportedDisplayFeatures"]);
        }
    } catch (ManagementException e) {
        MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
    }

In my case, I'm still stuck, because it is returning the "scaled down" resolution of each monitor. One of mine is a 4K display, being reported as 2560x1440.

scone
  • 566
  • 1
  • 4
  • 12