gpt4 book ai didi

c# - 获取与显示设置中找到的匹配的显示名称

转载 作者:太空宇宙 更新时间:2023-11-03 11:31:55 32 4
gpt4 key购买 nike

在编写 WPF 应用程序时,我想获取在标准 Windows 显示设置对话框中找到的显示名称。我试过 WMI 查询 Win32_DesktopMonitor 和 System.Windows.Forms.Screen.AllScreens。

标准窗口显示设置列表中显示的名称是:

Mobile PC Display
DELL 2407WFP

Win32_DesktopMonitor 提供以下内容(已删除无关信息):

DISPLAY 1
Caption = Generic PnP Monitor
CreationClassName = Win32_DesktopMonitor
Description = Generic PnP Monitor
DeviceID = DesktopMonitor1
MonitorManufacturer = (Standard monitor types)
MonitorType = Generic PnP Monitor
Name = Generic PnP Monitor
PNPDeviceID = DISPLAY\DELA017\5&2F0149CC&0&UID1078064

DISPLAY 2
Caption = Generic PnP Monitor
CreationClassName = Win32_DesktopMonitor
Description = Generic PnP Monitor
DeviceID = DesktopMonitor2
MonitorManufacturer = (Standard monitor types)
MonitorType = Generic PnP Monitor
Name = Generic PnP Monitor
PNPDeviceID = DISPLAY\CMO1720\4&164FD10C&0&UID67568640

System.Windows.Forms.Screen.AllScreens 提供了一个设备列表(去除了不相关的信息):

DISPLAY 1
DeviceName = \\.\DISPLAY1

DISPLAY 2
DeviceName = \\.\DISPLAY3

显然,我应该能够将 DeviceName、DeviceID 或 PNPDeviceID 与其他地方的列表进行交叉引用以获取名称,不是吗?

请不要为此打扰我,我用谷歌搜索了我能想到的所有内容,但我找到的只是关于 AllScreens 和 Win32_DesktopMonitor 的信息,但没有找到我们在标准 Windows 显示设置对话框中看到的显示名称。

非常感谢。

最佳答案

看起来有人在 MSDN Forums 上问过这个完全相同的问题.

其中有两个相关的答案,我将在此处复制:

I am not sure exactly what you mean by monitor name, the unique monitor name? If when you call EnumDisplayDevices to enumerate the monitor you can specify the following flag: EDD_GET_DEVICE_INTERFACE_NAME then in the DeviceID field of the DISPLAY_DEVICE structure you will see the unique monitor name.

其次是:

Thanks, your solution was almost 100% there. The only thing I needed to add was a second call to EnumDisplayDevices and passing in the DeviceName returned from the first call. Then the DeviceName is populated with the Monitor's name and not the Video card. Perfect!

我自己没有这样做,所以我无法验证它是否有效,但根据 MSDN 线程的 OP 说它对他有效,这似乎令人鼓舞。

关于c# - 获取与显示设置中找到的匹配的显示名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7486485/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com