如何将重复的监视器检测为单独的屏幕 [英] How to detect duplicated monitors as separate screens

查看:99
本文介绍了如何将重复的监视器检测为单独的屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题中使用答案可以获取屏幕"计数.但是,这似乎不适用于设置为重复"的监视器(报告了一个监视器而不是2个).我的应用程序提示用户从VGA切换到HDMI(这是在具有两个输出端口的设备上),然后输入您看到了吗?".屏幕上提示您验证两个视频端口是否正常工作.

Using the answer in this question I can get the "screen" count. However, this doesn't seem to work with monitors that are set to "duplicate" (one monitor is reported instead of 2). My application prompts a user to switch from VGA to HDMI (this is on a device with both output ports), and then puts a "can you see this?" prompt on screen to verify that both video ports are working.

我试图在显示提示之前检测到开关已发生,但是由于上述问题,代码没有看到监视器计数递减,而是递增(这就是我检测开关的方式).

I am trying to detect that the switch has happened before showing the prompt, but due to the above mentioned problem the code does not see the monitor count decrement, then increment (that is how I am detecting the switch).

如果所有内容都设置为重复,我如何检测视频设备切换?如果将监视器设置为扩展",则现有代码有效.还有一个内部视频设备也总是存在(不尝试对其进行测试).

How can I detect the video device switch if everything is set to duplicate? The existing code works if the monitors are set to "extend". There is an internal video device that is always present as well (not trying to test this one).

推荐答案

请参见此问题并使用提供的(并在答案中固定的)包装器来显示QueryDisplayConfig.

See This question and use the provided (and fixed in the answer) wrapper for QueryDisplayConfig.

更改导入的签名,使 out DisplayConfigTopologyId拓扑作为最后一个参数.

change the signature of the import to have out DisplayConfigTopologyId topology as the last parameter.

使用 QueryDisplayFlags.DatabaseCurrent 作为显示标志,否则将获得状态87(无效参数)

Use the QueryDisplayFlags.DatabaseCurrent for the display flags, otherwise you'll get status 87 (invalid parameter)

在调用QueryDisplayFlags之后,拓扑将为 Clone Extend 等.

After calling QueryDisplayFlags the topology will be Clone, Extend etc.

调用方法...

var status = CCDWrapper.QueryDisplayConfig(
    CCDWrapper.QueryDisplayFlags.DatabaseCurrent,
    ref numPathArrayElements, pathInfoArray, ref numModeInfoArrayElements,
    modeInfoArray, out currentTopologyId);

在我的测试中, numPathArrayElements 总是作为当前正在使用的监视器数量返回.如果将其更改为仅显示屏幕1",则表示1个屏幕,内部拓扑.回到仅显示屏幕2"时,外部显示了1个屏幕.克隆"显示2个屏幕.

In my tests numPathArrayElements always came back as the number of monitors currently In Use. If I changed it to "Show Only Screen 1", It said 1 screen, topology internal. "Show Only Screen 2" came back with 1 screen external. "Cloned" showed 2 screens.

这篇关于如何将重复的监视器检测为单独的屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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