WMI获取所有的显示器不返回所有显示器 [英] WMI Get All Monitors Not Returning All Monitors

查看:1984
本文介绍了WMI获取所有的显示器不返回所有显示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用WMI Win32_MonitorDesktop 来获取系统中的所有监视器的信息。

I am using WMI Win32_MonitorDesktop to get all the monitors information on the system.

不过它只返回一。我已经尝试过在几台计算机,而且他们肯定对他们有多个显示器,连接和工作。

However it only returns one. I have tried it on several computers, and they definitely have multiple monitors on them, connected and working.

ManagementObjectSearcher monitorObjectSearch = new ManagementObjectSearcher("SELECT * FROM Win32_DesktopMonitor");

foreach (ManagementObject monitor in monitorObjectSearch.Get())
{
      Debug.WriteLine(monitor["Description"]);
}



有谁知道为什么我只得到1个显示器回来了?

Does anyone know why i'm only getting 1 monitor returned?

另外,如果我monitorObjectSearch.Get()的返回值赋值给一个变量,我无法评价即时窗口作为函数总是超时Count属性。

Also if I assign the return value of monitorObjectSearch.Get() to a variable, I am unable to evaluate the Count property in the immediate window as the function always times out.

推荐答案

我试图解决在许多系统(从WinXP的SP3之后到Win10)使用WMI这个问题,我就得到了不同的结果不同的机器。
有两个表,可用来存储当前的显示器设置。首先是 Win32_DesktopMonitor 的中的 CIMV2 的命名空间,二是的 WMIMonitorID 的中的 WMI 的命名空间。
。如果其中一人只有一个记录(在多显示器设置),那么第二个将所有条目。

I tried to resolve this problem using WMI on many systems (from WinXP-SP3 up to Win10), and I got different results on different machines. There are two tables, where current monitor setting can be stored. First is Win32_DesktopMonitor in cimv2 namespace, second is WMIMonitorID in wmi namespace. If one of them has only one record (in multi display setting), then second will have all of entries.

然后让显示器的驱动程序名称,一个人应该会发现这些设备与PnPDeviceID在记录的 Win32_PnPEntity 的发现,从这些表的表中的 CIMV2 的命名空间。您可以检查样品溶液这里

Then to get driver name of monitor, one should find devices with PnPDeviceID found in records from those tables in Win32_PnPEntity table, in cimv2 namespace. You can check sample solution here.

这篇关于WMI获取所有的显示器不返回所有显示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆