如何在 Windows 中获取用于特定显示器的显示适配器?
在 Mac 上,我可以使用以下命令打印出用于特定显示器的适配器:
io_registry_entry_t dspPort = CGDisplayIOServicePort(displays[i]);
CFDataRef model_;
model_ = (CFDataRef)IORegistryEntrySearchCFProperty(dspPort,kIOServicePlane,CFSTR("model"),
kCFAllocatorDefault,
kIORegistryIterateRecursively | kIORegistryIterateParents);
if (model_) {
newLine();
String model((const char*)CFDataGetBytePtr(model_), CFDataGetLength(model_));
log.printf("Adapter: %s", model.buf);
CFRelease(model_);
}
示例输出 - 适配器:AMD Radeon HD 6750M
其中 displays[i]
是使用 CGGetActiveDisplayList(nDisplays, Displays, &nDisplays);
填充
的 有没有办法做到这一点Windows 上的等效操作?我正在使用 EnumDisplayMonitors
循环浏览所有显示器。
我可以使用 EnumDisplayDevices
获取适配器列表,但如何查看哪个显示器连接到哪个适配器?
编辑
使用:
for (int i=0; EnumDisplayDevicesA(monitorInfo.szDevice, i, &dev, 0); i++) {
newLine();
log.printf("Display Device: %s",(char*)dev.DeviceString);
}
我可以获取显示器本身的设备名称,但不能获取它们所连接的适配器!
On a Mac, I can use the following to print out the adapter used for a particular monitor:
io_registry_entry_t dspPort = CGDisplayIOServicePort(displays[i]);
CFDataRef model_;
model_ = (CFDataRef)IORegistryEntrySearchCFProperty(dspPort,kIOServicePlane,CFSTR("model"),
kCFAllocatorDefault,
kIORegistryIterateRecursively | kIORegistryIterateParents);
if (model_) {
newLine();
String model((const char*)CFDataGetBytePtr(model_), CFDataGetLength(model_));
log.printf("Adapter: %s", model.buf);
CFRelease(model_);
}
Example output- Adapter: AMD Radeon HD 6750M
Where displays[i]
is populated using CGGetActiveDisplayList(nDisplays, displays, &nDisplays);
Is there any way to do the equivalent operation on Windows? I'm cycling through all displays using EnumDisplayMonitors
.
I can get a list of adapters using EnumDisplayDevices
, but how do I see which monitor is attached to which adapter?
Edit
Using:
for (int i=0; EnumDisplayDevicesA(monitorInfo.szDevice, i, &dev, 0); i++) {
newLine();
log.printf("Display Device: %s",(char*)dev.DeviceString);
}
I can get the device names of the monitors themselves, but not the adapters they are connected to!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以想到三种方法:
EnumDisplayDevices
文档提到dwFlags
参数可用于获取可与 SetupAPI 函数。该 API 为 提供了一整套功能获取设备信息。因此,也许您可以从EnumDisplayDevices
获取设备 ID,将其粘贴到某个 SetupAPI 函数中以获取监视器设备结构,并从那里获取显示适配器设备 ID。您可以使用
Win32_VideoController
类通过 WMI 获取显示适配器信息。我可以想象某些 DirectX API 可用于获取有关已安装的图形硬件的信息。
I can think of three approaches:
The
EnumDisplayDevices
documentation mentions that thedwFlags
argument can be used to get a device ID which can be used with the SetupAPI functions. That API provide a whole range of functions to get device information. So maybe you can get the device ID fromEnumDisplayDevices
, stick that into some SetupAPI function to get the monitor device struct, and get the display adapter device ID from there.You can probably use the
Win32_VideoController
class via WMI to get the display adapter information.I can imagine that some DirectX API is available for getting information about the installed graphics hardware.