有没有办法让显示器在vb中获得最佳分辨率? 基于建议的最优分辨率 如果您想要CRT的最佳分辨率,那么您可以遵循Microsoft’s advice(因为CRT没有原生分辨率): For a CRT monitor, it’s important
如果您想要CRT的最佳分辨率,那么您可以遵循Microsoft’s advice(因为CRT没有原生分辨率):
For a CRT monitor, it’s important to change the screen resolution to
the highest resolution available that provides 32-bit color and at
least a 72-Hertz refresh rate.
如果您想要LCD显示器的最佳分辨率,则必须使用其原始分辨率.通常它是显示器可用的最高分辨率.
获得最佳分辨率的方法
您可以从各种来源获取解决方案信息:
> Windows API(带User32.dll)
> DirectX(使用SDK)
> Windows Management Instrumentation(a.k.a.WMI)
基于VB代码的最优分辨率
我将使用一些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”))获取它