tags:

views:

70

answers:

3

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.

A: 

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
@SwDevMan81 That's the query I listed in the question that doesn't work :)!
mint
@snow - See update, let me know if that helps
SwDevMan81
@SwDevMan81 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 : <Standard Monitior Types> which isn't what I was looking for.
mint
@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
+2  A: 

you may want to try this

http://myitforum.com/cs2/blogs/rzander/archive/2009/03/30/wmi-provider-to-list-the-monitors-serialnr-and-model-name.aspx

Also i use WMI Explorer to check around for WMI Settings

http://www.ks-soft.net/hostmon.eng/wmi/index.htm

Cheers

Iain
A: 

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