当前位置:编程学习 > C#/ASP.NET >>

VB.NET中如何获取当前屏幕的分辨率?

VB.NET中如何获取当前屏幕的分辨率?
如:我现在电脑是1024*768  若我把改成800*600  VB.NET要能够自动获取已经是800*600 --------------------编程问答-------------------- 获取可用

Screen.PrimaryScreen.Bounds --------------------编程问答-------------------- 长 * 宽
TextBox2.Text = My.Computer.Screen.Bounds.Width.ToString & "*" & My.Computer.Screen.Bounds.Height.ToString

My.Computer.Screen.Bounds.Width.ToString  获取显示屏幕的长度
My.Computer.Screen.Bounds.Height.ToString 获取显示屏幕的高度

--------------------编程问答-------------------- 楼上正解! --------------------编程问答--------------------

Private Sub Lobdotcn()
Dim strComputer As String = "."
Dim objWMIService As Object = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
 & strComputer & "\root\cimv2")
 Dim objItem As Object
 Dim colItems As Object = objWMIService.ExecQuery _
 ("Select * from Win32_DesktopMonitor")
For Each objItem In colItems
 MsgBox(objItem.ScreenWidth & " * " & objItem.ScreenHeight)
Next
End Sub
--------------------编程问答--------------------        Dim Monitor_Num%, ScreenLocateX%, ScreenLocateY%, ScreenLeft%, ScreenTop, ScreenWidth%, ScreenHeight%
        Monitor_Num = SystemInformation.MonitorCount
        Monitor_Num = Screen.AllScreens.Length
        ScreenLocateX = Screen.AllScreens(0).Bounds.Location.X
        ScreenLocateY = Screen.AllScreens(0).Bounds.Location.Y
        ScreenLeft = Screen.AllScreens(0).Bounds.Left
        ScreenTop = Screen.AllScreens(0).Bounds.Top
        ScreenWidth = Screen.AllScreens(0).Bounds.Width
        ScreenHeight = Screen.AllScreens(0).Bounds.Height
        
        ScreenLocateX = Screen.AllScreens(1).Bounds.Location.X
        ScreenLocateY = Screen.AllScreens(1).Bounds.Location.Y
        ScreenLeft = Screen.AllScreens(1).Bounds.Left
        ScreenTop = Screen.AllScreens(1).Bounds.Top
        ScreenWidth = Screen.AllScreens(1).Bounds.Width
        ScreenHeight = Screen.AllScreens(1).Bounds.Height
--------------------编程问答-------------------- --------------------编程问答--------------------
引用楼主 ymjvko 的回复:
VB.NET中如何获取当前屏幕的分辨率?
如:我现在电脑是1024*768  若我把改成800*600  VB.NET要能够自动获取已经是800*600

你可以弄一个循环,每隔多少秒就检查一次分辨率,如有变化就触发某个事件。Windows不会把改变分辨率这个消息无缘无故的提交给程序的。
补充:.NET技术 ,  VB.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,