Get and Set Screen Resolution

后端 未结 6 1664
灰色年华
灰色年华 2020-11-27 18:07

How can I collect and change screen resolution using Visual C#?

6条回答
  •  伪装坚强ぢ
    2020-11-27 18:32

    If you want to collect screen resolution you can run the following code within a WPF window (the window is what the this would refer to):

    System.Windows.Media.Matrix m = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice;
    Double dpiX = m.M11 * 96;
    Double dpiY = m.M22 * 96;
    

提交回复
热议问题