Vb.net 使用两个监视器获取屏幕大小

Vb.net 使用两个监视器获取屏幕大小,vb.net,Vb.net,我使用此代码获取屏幕大小的高度: Dim hdcSrc As IntPtr = User32.GetWindowDC(handle) Dim windowRect As New User32.RECT User32.GetWindowRect(handle, windowRect) Dim width As Integer = windowRect.right - windowRect.left Dim height As Integer = windowRect.bot

我使用此代码获取屏幕大小的高度:

 Dim hdcSrc As IntPtr = User32.GetWindowDC(handle)       
 Dim windowRect As New User32.RECT
 User32.GetWindowRect(handle, windowRect)
 Dim width As Integer = windowRect.right - windowRect.left
 Dim height As Integer = windowRect.bottom - windowRect.top

现在,当我们有两个不同尺寸的显示器。哪一个被视为默认监视器?

所有这些都在类中可用:


Net框架中有一个有用的类,可以轻松地替换代码

使用以下方法获得主屏幕:

Screen.PrimaryScreen
例如,上面的代码可以使用

Dim area As Rectangle = Screen.PrimaryScreen.Bounds
Console.WriteLine("Width: " & area.Width.ToString)
Console.WriteLine("Height: " & area.Height.ToString)
你试过这个?还有这个
Screen.PrimaryScreen
Dim area As Rectangle = Screen.PrimaryScreen.Bounds
Console.WriteLine("Width: " & area.Width.ToString)
Console.WriteLine("Height: " & area.Height.ToString)