显示名称如何与设备名称相对应? [英] How does the display name correspond to the device name?

查看:80
本文介绍了显示名称如何与设备名称相对应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    HI,  我使用DisplayConfigGetDeviceInfo函数成功获取显示在桌面上的显示名称 - >显示,然后EnumDisplayMonitors获取所有监视器设备名称[\\\\\\\\ DISPLAY1]
$


   但是如果有多个监视器,我如何知道哪个设备对应于受监视的名称?

      I used the DisplayConfigGetDeviceInfo function to successfully get the display name, which appeared on the desktop - > display, and then EnumDisplayMonitors got all the monitor device names [\\\\.\\DISPLAY1]

    But if there are multiple monitors, how do I know which device corresponds to the monitored name?

推荐答案

你好,

您可能需要阅读并使用
EnumDisplayDevices
(),根据msdn doc的备注,

"要获取显示监视器上的信息,首先调用EnumDisplayDevices,并将lpDevice设置为NULL。然后调用EnumDisplayDevices,将lpDevice设置为DISPLAY_DEVICE.DeviceName,从第一次调用EnumDisplayDevices并将iDevNum设置为零。然后
DISPLAY_DEVICE.DeviceString是监视器名称。"

和"要查询与适配器关联的所有监视器设备,请在循环中调用EnumDisplayDevices,并将lpDevice设置为适配器名称iDevNum设置为从0开始,iDevNum设置为递增,直到函数失败。请注意,每次调用监视器信息时,DISPLAY_DEVICE.DeviceName
都会更改,因此您必须保存适配器名称。当没有适配器的监视器时,该功能失败。"

以下是示例代码:

You may need to read and use EnumDisplayDevices(), According to the Remarks of the msdn doc,
"To obtain information on a display monitor, first call EnumDisplayDevices with lpDevice set to NULL. Then call EnumDisplayDevices with lpDevice set to DISPLAY_DEVICE.DeviceName from the first call to EnumDisplayDevices and with iDevNum set to zero. Then DISPLAY_DEVICE.DeviceString is the monitor name."
and "To query all monitor devices associated with an adapter, call EnumDisplayDevices in a loop with lpDevice set to the adapter name, iDevNum set to start at 0, and iDevNum set to increment until the function fails. Note that DISPLAY_DEVICE.DeviceName changes with each call for monitor information, so you must save the adapter name. The function fails when there are no more monitors for the adapter."
Here is the sample code:

        DISPLAY_DEVICE dd;
	dd.cb = sizeof(DISPLAY_DEVICE);
	int i = 0;
	while (EnumDisplayDevices(NULL, i, &dd, 0))
	{
		CHAR name[128] = { 0 };
		strcpy(name, dd.DeviceName);
		cout << "Device Name : " << dd.DeviceName;
		if (EnumDisplayDevices(name, i, &dd, 0))
			cout<<"\tMonitor Name : " << dd.DeviceString <<endl;
		else
			cout << "\tNo Monitor" << endl;
		i++;
	}



或者你也可以从msdn doc
here


祝你好运,

Best regards,


Drake

Drake


这篇关于显示名称如何与设备名称相对应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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