Get PC's Monitor Information Using .NET / WMI

前端 未结 4 1375
余生分开走
余生分开走 2021-01-13 00:30

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 quer

4条回答
  •  不知归路
    2021-01-13 01:01

    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.

提交回复
热议问题