有没有办法让显示器在vb中达到最佳分辨率?
答案 0 :(得分:4)
如果您想要CRT的最佳分辨率,那么您可以关注Microsoft's advice(因为CRT没有原生分辨率):
对于CRT显示器,将屏幕分辨率更改为 可用的最高分辨率,提供32位颜色和 至少72赫兹的刷新率。
如果您想要LCD显示器的最佳分辨率,则必须使用其原生分辨率。通常它是显示器可用的最高分辨率。
您可以从各种来源获取解决方案信息:
我将使用一些WMI来查询分辨率信息。我们可以使用Win32_VideoSettings类,它通过视频控制器为我们提供可用的分辨率,但我有一些有趣/悲伤/空的结果。对于这个,我直接使用CIM_VideoControllerResolution类来获得最大分辨率:
Imports System.Management
'...
Public Function GetMaximumResolution() As ManagementObject
Dim className As String = "CIM_VideoControllerResolution"
Dim computerName As String = "."
Dim managementPath As New ManagementPath("\\" & computerName & "\root\cimv2:" & className)
Dim scope As New ManagementScope(managementPath)
Dim videoCtrlrRes As ManagementObjectCollection
Using searcher As ManagementObjectSearcher = New ManagementObjectSearcher("select * from " & className)
searcher.Scope = scope
videoCtrlrRes = searcher.Get()
End Using
Dim videoCtrlrResList As New List(Of ManagementObject)
For Each videoCtrlResItem In videoCtrlrRes
'Console.WriteLine(videoCtrlResItem("Description"))
videoCtrlrResList.Add(videoCtrlResItem)
Next
Dim maximumResolution As ManagementObject = videoCtrlrResList.
OrderBy(Function(vidSetting) vidSetting("HorizontalResolution")).
ThenBy(Function(vidSetting) vidSetting("VerticalResolution")).
ThenBy(Function(vidSetting) vidSetting("NumberOfColors")).
LastOrDefault()
'Console.WriteLine(maximumResolution("Description"))
Return maximumResolution
End Function
注意:如果您想获得resfresh率,可以使用'RefreshRate'属性(例如vidSetting(“RefreshRate”))来获取它。