简体   繁体   English

将EnumDisplaySettings与非标准设备名称一起使用

[英]Use EnumDisplaySettings with non-standard Device Name

I have have found out a monitors' device name by inspecting the value DEV_BROADCAST_DEVICEINTERFACE.dbcc_name and I am attempting to use that device name inside the function EnumDisplaySettings() (the device name is the first parameter of that function). 我已经通过检查值DEV_BROADCAST_DEVICEINTERFACE.dbcc_name找到了监视器的设备名称 ,并且我试图在函数EnumDisplaySettings()使用该设备名称(设备名称是该功能的第一个参数)。

My Problem: The function EnumDisplaySettings() always returns 0, ie, fails. 我的问题:函数EnumDisplaySettings()始终返回0,即失败。 I believe it fails because MSDN says the first parameter of EnumDisplaySettings() should be a DISPLAY_DEVICE.DeviceName returned from EnumDisplayDevices whereas my device name is from DEV_BROADCAST_DEVICEINTERFACE.dbcc_name . 我相信它会失败,因为MSDN表示EnumDisplaySettings()的第一个参数应该是DISPLAY_DEVICE.DeviceName returned from EnumDisplayDevicesDISPLAY_DEVICE.DeviceName returned from EnumDisplayDevices而我的设备名称是DEV_BROADCAST_DEVICEINTERFACE.dbcc_name

Using DEV_BROADCAST_DEVICEINTERFACE.dbcc_name I get the device name \\\\?\\DISPLAY#GSM3AD7#5&20a3f50d&0&UID513#{866519b5-3f07-4c97-b7df-24 c5d8a8ccb8} for my second monitor whereas EnumDisplayDevices() gives me the device name \\\\.\\DISPLAYV1 . 使用DEV_BROADCAST_DEVICEINTERFACE.dbcc_name获得设备名称\\\\?\\DISPLAY#GSM3AD7#5&20a3f50d&0&UID513#{866519b5-3f07-4c97-b7df-24 c5d8a8ccb8}作为我的第二个监视器,而EnumDisplayDevices()给我设备名称\\\\.\\DISPLAYV1

Is it possible to use EnumDisplaySettings() where the 1st parameter is a device name retrieved from the function DEV_BROADCAST_DEVICEINTERFACE.dbcc_name? 是否可以使用EnumDisplaySettings(),其中第一个参数是从函数DEV_BROADCAST_DEVICEINTERFACE.dbcc_name检索的设备名称?

The reason why I ask is: when a second monitor gets connected to the computer I want to change that monitors display settings. 我问的原因是:当第二台显示器连接到计算机时,我想更改该显示器的显示设置。 But upon monitor connection I am notified of its device name through DEV_BROADCAST_DEVICEINTERFACE.dbcc_name which (as I explained above) is a different name to what EnumDisplayDevices() returns for the exact same device. 但是,在监视器连接时,我通过DEV_BROADCAST_DEVICEINTERFACE.dbcc_name了它的设备名称,该名称与EnumDisplayDevices()为完全相同的设备返回的名称不同(如上所述)。 And I dont know how I could identify that second monitor by enumerating though all display devices using EnumDisplayDevices()? 而且我不知道如何枚举所有使用EnumDisplayDevices()的显示设备来识别第二台显示器? Any ideas how I could enumerate though all display devices using EnumDisplayDevices() and identify the correct monitor/device that was just connected to the computer? 我有什么想法可以枚举所有使用EnumDisplayDevices()的显示设备,并标识刚刚连接到计算机的正确监视器/设备吗?

I can't guarantee it, but I'd guess that a display device retains its name as long as it remains connected. 我不能保证,但是我猜想只要保持连接状态,显示设备就会保留其名称。

On that assumption, I'd run EnumDisplayDevices when your program starts. 在这种假设下,我将在程序启动时运行EnumDisplayDevices When the new monitor is connected, use EnumDisplayDevices again, and compare the list of devices to your previous list, then EnumDisplaySettings on whichever device was newly added to the list. 连接新监视器后,再次使用EnumDisplayDevices ,并将设备列表与以前的列表进行比较,然后将新添加到该列表中的任何设备上的EnumDisplaySettings进行比较。

When you're done with that, replace the old list with the new list, and you're ready for the next time the user plugs in another monitor. 完成后,将旧列表替换为新列表,您就可以为下一次用户插入另一台显示器做好准备了。

Have a look at these previous answers for clues to help you turn a DEV_BROADCAST_DEVICEINTERFACE.dbcc_name value into a suitable DISPLAY_DEVICE.DeviceName value: 请查看以下先前的答案以获取帮助的线索,以帮助您将DEV_BROADCAST_DEVICEINTERFACE.dbcc_name值转换为合适的DISPLAY_DEVICE.DeviceName值:

acessing dbcc_name from DEV_BROADCAST_DEVICEINTERFACE win32 programming 从DEV_BROADCAST_DEVICEINTERFACE Win32编程中访问dbcc_name

How to get friendly device name from DEV_BROADCAST_DEVICEINTERFACE and Device Instance ID 如何从DEV_BROADCAST_DEVICEINTERFACE和设备实例ID获取友好的设备名称

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM