【问题标题】:GetInches of Screen SizeGetInches 屏幕尺寸
【发布时间】:2014-03-28 10:34:53
【问题描述】:

我目前正在运行它

       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"

【问题讨论】:

  • 查询返回整数,单位为厘米。所以当然它永远不会比 +/- 0.5 厘米更准确。您想要更高的准确性,显然您对这个查询没有用处。
  • 我明白了,那我得试试别的了。但我迷失在想法中。我没有太多关于如何解决这个问题的知识。
  • 感谢 Hans ;) 我尝试了 Matt Wilko 的以下帖子,但没有解决问题。我的程序是在笔记本电脑上显示所有信息,将其导出为 csv 文件。这用于销售笔记本电脑等。所以这个解决方案应该显示正确的屏幕尺寸。我希望这能让我更清楚为什么我需要合适的尺寸。那么我怎样才能得到更精确的尺寸呢?

标签: vb.net wmi screen-size inches


【解决方案1】:

我认为以下应该可行:

    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

【讨论】:

  • 这显示在我的 Lenovo G580 16.3" 而不是 15.6" 这不使用 DPI 吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多