问题
在使用以下代码输出显示设备信息时:
void WinDevice::ScreenManager::_UpdateDisplayDeviceList()
{
spdlog::info("=====GetInfoByEnumDisplayDevices start=====");
DISPLAY_DEVICE displayDevice;
displayDevice.cb = sizeof(DISPLAY_DEVICE);
DWORD deviceIndex = 0;
while (EnumDisplayDevices(nullptr, deviceIndex, &displayDevice, 0))
{
spdlog::info("Display Device DeviceName:{0}, DeviceString:{1}, DeviceID:{2}, DeviceKey:{3}.",
displayDevice.DeviceName, displayDevice.DeviceString, displayDevice.DeviceID, displayDevice.DeviceKey);
_displayDeviceList.push_back(displayDevice);
deviceIndex++;
}
spdlog::info("=====GetInfoByEnumDisplayDevices end=====");
}
得到的输出如下:
[2024-10-08 15:30:46.016] [info] =====GetInfoByEnumDisplayDevices start=====
[2024-10-08 15:30:46.020] [info] Display Device DeviceName:\\.\DISPLAY1, DeviceString:Intel(R) Iris(R) Xe Graphics, DeviceID:PCI\VEN_8086&DEV_A7A0&SUBSYS_185D1043&REV_04, DeviceKey:\Registry\Machine\System\CurrentControlSet\Control\Video\{CCF64491-F46D-11ED-ABE5-806E6F6E6963}\0000.
[2024-10-08 15:30:46.020] [info] Display Device DeviceName:\\.\DISPLAY2, DeviceString:Intel(R) Iris(R) Xe Graphics, DeviceID:PCI\VEN_8086&DEV_A7A0&SUBSYS_185D1043&REV_04, DeviceKey:\Registry\Machine\System\CurrentControlSet\Control\Video\{CCF64491-F46D-11ED-ABE5-806E6F6E6963}\0001.
[2024-10-08 15:30:46.020] [info] Display Device DeviceName:\\.\DISPLAY3, DeviceString:Intel(R) Iris(R) Xe Graphics, DeviceID:PCI\VEN_8086&DEV_A7A0&SUBSYS_185D1043&REV_04, DeviceKey:\Registry\Machine\System\CurrentControlSet\Control\Video\{CCF64491-F46D-11ED-ABE5-806E6F6E6963}\0002.
[2024-10-08 15:30:46.020] [info] Display Device DeviceName:\\.\DISPLAY4, DeviceString:Intel(R) Iris(R) Xe Graphics, DeviceID:PCI\VEN_8086&DEV_A7A0&SUBSYS_185D1043&REV_04, DeviceKey:\Registry\Machine\System\CurrentControlSet\Control\Video\{CCF64491-F46D-11ED-ABE5-806E6F6E6963}\0003.
[2024-10-08 15:30:46.021] [info] Display Device DeviceName:\\.\DISPLAY5, DeviceString:NVIDIA GeForce RTX 4060 Laptop GPU, DeviceID:PCI\VEN_10DE&DEV_28E0&SUBSYS_185D1043&REV_A1, DeviceKey:\Registry\Machine\System\CurrentControlSet\Control\Video\{0B53284F-6469-11EF-ACCD-581CF8B1D992}\0000.
[2024-10-08 15:30:46.021] [info] Display Device DeviceName:\\.\DISPLAY6, DeviceString:NVIDIA GeForce RTX 4060 Laptop GPU, DeviceID:PCI\VEN_10DE&DEV_28E0&SUBSYS_185D1043&REV_A1, DeviceKey:\Registry\Machine\System\CurrentControlSet\Control\Video\{0B53284F-6469-11EF-ACCD-581CF8B1D992}\0001.
[2024-10-08 15:30:46.021] [info] Display Device DeviceName:\\.\DISPLAY7, DeviceString:NVIDIA GeForce RTX 4060 Laptop GPU, DeviceID:PCI\VEN_10DE&DEV_28E0&SUBSYS_185D1043&REV_A1, DeviceKey:\Registry\Machine\System\CurrentControlSet\Control\Video\{0B53284F-6469-11EF-ACCD-581CF8B1D992}\0002.
[2024-10-08 15:30:46.021] [info] Display Device DeviceName:\\.\DISPLAY8, DeviceString:NVIDIA GeForce RTX 4060 Laptop GPU, DeviceID:PCI\VEN_10DE&DEV_28E0&SUBSYS_185D1043&REV_A1, DeviceKey:\Registry\Machine\System\CurrentControlSet\Control\Video\{0B53284F-6469-11EF-ACCD-581CF8B1D992}\0003.
[2024-10-08 15:30:46.021] [info] Display Device DeviceName:\\.\DISPLAY9, DeviceString:OrayIddDriver Device, DeviceID:Root\OrayIddDriver, DeviceKey:\Registry\Machine\System\CurrentControlSet\Control\Video\{116A9A5E-4190-11EE-AC03-581CF8B1D992}\0000.
[2024-10-08 15:30:46.021] [info] Display Device DeviceName:\\.\DISPLAY10, DeviceString:OrayIddDriver Device, DeviceID:Root\OrayIddDriver, DeviceKey:\Registry\Machine\System\CurrentControlSet\Control\Video\{116A9A5E-4190-11EE-AC03-581CF8B1D992}\0001.
[2024-10-08 15:30:46.021] [info] Display Device DeviceName:\\.\DISPLAY11, DeviceString:OrayIddDriver Device, DeviceID:Root\OrayIddDriver, DeviceKey:\Registry\Machine\System\CurrentControlSet\Control\Video\{116A9A5E-4190-11EE-AC03-581CF8B1D992}\0002.
[2024-10-08 15:30:46.021] [info] Display Device DeviceName:\\.\DISPLAY12, DeviceString:OrayIddDriver Device, DeviceID:Root\OrayIddDriver, DeviceKey:\Registry\Machine\System\CurrentControlSet\Control\Video\{116A9A5E-4190-11EE-AC03-581CF8B1D992}\0003.
[2024-10-08 15:30:46.021] [info] Display Device DeviceName:\\.\DISPLAY13, DeviceString:OrayIddDriver Device, DeviceID:Root\OrayIddDriver, DeviceKey:\Registry\Machine\System\CurrentControlSet\Control\Video\{116A9A5E-4190-11EE-AC03-581CF8B1D992}\0004.
[2024-10-08 15:30:46.021] [info] =====GetInfoByEnumDisplayDevices end=====
同一个 DeviceID的显卡会有多个结果, 这是为何?
原因
一个 DeviceID有多个 DeviceName(如 \\.\DISPLAY1, \\.\DISPLAY2, 等)可能代表了同一物理显示设备的不同逻辑显示器。具体分析如下:
1. Intel(R) Iris(R) Xe Graphics 显卡
-
\\.\DISPLAY1到\\.\DISPLAY4都属于 Intel(R) Iris(R) Xe Graphics 显卡。 -
它们的
DeviceID是相同的:PCI\VEN_8086&DEV_A7A0&SUBSYS_185D1043&REV_04,表示它们使用的是同一块 Intel 显卡。 -
DeviceKey是\Registry\Machine\System\CurrentControlSet\Control\Video\{CCF64491-F46D-11ED-ABE5-806E6F6E6963}\000X,其中0000到0003分别代表了不同的显示输出。解释: 这些
DeviceName很可能是同一块显卡的不同显示器接口(如 HDMI、DisplayPort、内置屏幕等)对应的条目。这在多显示器配置中非常常见,每个输出端口都可能对应一个DeviceName,即使它们共享相同的硬件资源(同一块显卡)。
2. NVIDIA GeForce RTX 4060 Laptop GPU
-
\\.\DISPLAY5到\\.\DISPLAY8都属于 NVIDIA GeForce RTX 4060 Laptop GPU。 -
这些条目的
DeviceID是相同的:PCI\VEN_10DE&DEV_28E0&SUBSYS_185D1043&REV_A1,对应于这块 NVIDIA 显卡。 -
它们的
DeviceKey是\Registry\Machine\System\CurrentControlSet\Control\Video\{0B53284F-6469-11EF-ACCD-581CF8B1D992}\000X,表示不同的显示输出。解释: 与 Intel 显卡类似,NVIDIA 显卡的多个
DeviceName对应的是不同的显示接口或输出配置。
3. OrayIddDriver Device
-
\\.\DISPLAY9到\\.\DISPLAY13属于OrayIddDriver Device,这是一个虚拟显示驱动程序。 -
它们的
DeviceID是Root\OrayIddDriver,这是一个虚拟设备。 -
结论:
-
DeviceKey是\Registry\Machine\System\CurrentControlSet\Control\Video\{116A9A5E-4190-11EE-AC03-581CF8B1D992}\000X,与前面的硬件显示设备不同。解释:
OrayIddDriver可能是某种远程桌面虚拟显示驱动,或用于创建虚拟显示设备的驱动程序(如远程连接或虚拟机)。这种驱动程序通常用于多显示器或虚拟屏幕环境,因此多个DeviceName对应同一虚拟驱动。
结论
多个 DeviceKey 对应同一个 DeviceName 是因为不同的显示输出(无论是硬件还是虚拟化)在系统中被视为独立的逻辑显示器。每个显示输出都有独立的注册表项(DeviceKey),尽管它们可能使用相同的物理显示设备或显卡。