查找所有显示器的编号和分辨率

发布于 2024-08-06 22:33:52 字数 35 浏览 6 评论 0原文

如何轮询窗口来查看连接的显示器以及它们运行的​​分辨率?

How would one poll windows to see what monitors are attached and what resolution they are running at?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你的呼吸 2024-08-13 22:33:52

在 C# 中:屏幕 Class 表示单个系统上的一个显示设备或多个显示设备。您需要 Bounds 属性。

foreach(var screen in Screen.AllScreens)
{
    // For each screen, add the screen properties to a list box.
    listBox1.Items.Add("Device Name: " + screen.DeviceName);
    listBox1.Items.Add("Bounds: " + screen.Bounds.ToString());
    listBox1.Items.Add("Type: " + screen.GetType().ToString());
    listBox1.Items.Add("Working Area: " + screen.WorkingArea.ToString());
    listBox1.Items.Add("Primary Screen: " + screen.Primary.ToString());
}

In C#: Screen Class Represents a display device or multiple display devices on a single system. You want the Bounds attribute.

foreach(var screen in Screen.AllScreens)
{
    // For each screen, add the screen properties to a list box.
    listBox1.Items.Add("Device Name: " + screen.DeviceName);
    listBox1.Items.Add("Bounds: " + screen.Bounds.ToString());
    listBox1.Items.Add("Type: " + screen.GetType().ToString());
    listBox1.Items.Add("Working Area: " + screen.WorkingArea.ToString());
    listBox1.Items.Add("Primary Screen: " + screen.Primary.ToString());
}
智商已欠费 2024-08-13 22:33:52

使用Screen 类

您可以查看 Screen.AllScreens 数组中的所有显示器,并使用 Bounds 属性检查每个显示器的分辨率和位置。

请注意,某些视频卡会将两个显示器合并为一个非常宽的屏幕,因此 Windows 认为只有一个显示器。如果你愿意,你可以检查屏幕的宽度是否超​​过其高度的两倍;如果是这样,它可能是一个水平跨度,您可以将其视为两个相等的屏幕。但是,这比较复杂,您不需要这样做。垂直跨度也受支持,但不太常见。

Use the Screen class.

You can see all of the monitors in the Screen.AllScreens array, and check the resolution and position of each one using the Bounds property.

Note that some video cards will merge two monitors into a single very wide screen, so that Windows thinks that there is only one monitor. If you want to, you could check whether the width of a screen is more than twice its height; if so, it's probably a horizontal span and you can treat it as two equal screens. However, this is more complicated and you don't need to do it. Vertical spans are also supported but less common.

平生欢 2024-08-13 22:33:52

http://msdn.microsoft.com/en-us/magazine/cc301462。 aspx

GetSystemMetrics 是一个方便的函数,您可以使用它来获取各种全局尺寸,例如图标的大小或窗口标题的高度。在 Windows 2000 中,有一些新参数(如 SM_CXVIRTUALSCREEN 和 SM_CYVIRTUALSCREEN)可获取多显示器系统的屏幕虚拟尺寸。 Windows 新手和专业人士都应该查看 GetSystemMetrics 的文档,以了解可以获得的所有不同系统指标(维度)。请参阅 http://msdn.microsoft 上的 Platform SDK 了解最新信息。 com/library/en-us/sysinfo/sysinfo_8fjn.asp。 GetSystemMetrics 是您经常需要使用的一个方便的功能,并且每个版本的 Windows 都会出现新功能。

http://msdn.microsoft.com/en-us/magazine/cc301462.aspx

GetSystemMetrics is a handy function you can use to get all sorts of global dimensions, like the size of an icon or height of a window caption. In Windows 2000, there are new parameters like SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN to get the virtual size of the screen for multiple monitor systems. Windows newbies—and pros, too—should check out the documentation for GetSystemMetrics to see all the different system metrics (dimensions) you can get. See the Platform SDK for the latest at http://msdn.microsoft.com/library/en-us/sysinfo/sysinfo_8fjn.asp. GetSystemMetrics is a handy function you frequently need to use, and new stuff appears with every version of Windows.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文