如何使用VB.NET检测屏幕DPI?

时间:2018-06-12 13:28:50

标签: windows vb.net

我需要屏幕DPI,所以我可以相应地调整我的程序。

所以我的问题是如何使用VB.NET检测屏幕DPI?

1 个答案:

答案 0 :(得分:0)

试试这个:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim g As Graphics = Me.CreateGraphics()
    MessageBox.Show("ScreenWidth:" & Screen.PrimaryScreen.Bounds.Width & " ScreenHeight:" & Screen.PrimaryScreen.Bounds.Height & vbCrLf & " DpiX:" & g.DpiX & " DpiY:" & g.DpiY)
End Sub