相关疑难解决方法(0)

Screen.AllScreen未提供正确的监视器计数

我在我的程序中做了类似的事情:

Int32 currentMonitorCount = Screen.AllScreens.Length;

if  (currentMonitorCount < 2)
{
   //Put app in single screen mode.
}
else
{
   //Put app in dual screen mode.
}
Run Code Online (Sandbox Code Playgroud)

非常重要我的应用程序可识别当前连接的监视器数量.

但是,在我多次插入/拔出显示器后,Screen.AllScreens.Length始终返回"2".

我的显示器知道它没有连接(它已进入'节电'模式),控制面板知道它没有连接(它只显示一个显示器).

那我错过了什么?我怎么知道只有一台显示器?

.net c# multiple-monitors windows-7 winforms

15
推荐指数
2
解决办法
1万
查看次数

如何获取每个显示器的缩放因子,例如 1、1.25、1.5

我知道以前曾有人问过这个问题,但我已经尝试了找到的所有答案,但似乎没有一个对我有用。答案似乎适用于单个显示器,或者需要窗口句柄,或者位于 WPF 应用程序中。我有一个没有 UI 的 C# 类库,它是从不同的语言一起调用的。

我被要求确定 C# 类库中连接到当前 PC 的每个显示器的缩放系数,例如 1、1.25、1.5 等。

我还需要提供每台显示器的分辨率和颜色深度。注册表确实保存了DpiValueWindows 10 中的 ,无论是什么。

Computer\HKEY_CURRENT_USER\Control Panel\Desktop\PerMonitorSettings
Run Code Online (Sandbox Code Playgroud)

但是我不知道如何将它们映射到 aScreen以获得返回的匹配分辨率

System.Windows.Forms.Screen.AllScreens
Run Code Online (Sandbox Code Playgroud)

那么有人有办法获取这些信息吗?

c# multiple-monitors class-library dpi

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×2

multiple-monitors ×2

.net ×1

class-library ×1

dpi ×1

windows-7 ×1

winforms ×1