0

我目前运行这个

       Private Sub GetInches()
    Dim searcher As New ManagementObjectSearcher( _
                "\root\WMI", _
                "SELECT * FROM WmiMonitorBasicDisplayParams")
    For Each queryObj As ManagementObject In searcher.Get()

        Dim width As Double = CByte(queryObj("MaxHorizontalImageSize")) / 2.54
        Dim height As Double = CByte(queryObj("MaxVerticalImageSize")) / 2.54
        Dim diagonal As Double = Decimal.Round(Math.Sqrt(width * width + height * height), 1, MidpointRounding.ToEven)
        tbVGARES.Text = diagonal
    Next



    searcher.Dispose()
End Sub

但是当我在几台笔记本电脑上运行它时,有时会出现英寸偏差。

1 个屏幕显示 15.5" 而屏幕是 15.6" 其他屏幕显示 14" 而屏幕是 13.7" 等等。

也许有人知道解决这个问题的方法?笔记本电脑液晶屏的标准尺寸为:

10,1" 11,6" 12,0"12,1"13" 13,3" 14" 14,1" 15" 15,4" 15,6" 16" 16,4" 17,1" 17, 3" 18,4"

4

1 回答 1

0

我认为以下应该有效:

    For Each scr In Screen.AllScreens
        Dim width = scr.Bounds.Width / Me.CreateGraphics.DpiX
        Dim height = scr.Bounds.Height / Me.CreateGraphics.DpiY
        Dim size = Math.Sqrt((width * width) + (height * height))
        Debug.WriteLine(String.Format("Screen {0} is Size {1:0.00} inches", scr.DeviceName, size))
    Next
于 2014-03-28T11:23:48.897 回答