Get PC's Monitor Information Using .NET / WMI

前端 未结 4 1400
余生分开走
余生分开走 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:10

    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.

提交回复
热议问题