public override void GetDpi(out float dpix, out float dpiy)
{
- IntPtr hDc = NativeMethods.GetDC(IntPtr.Zero);
- dpix = NativeMethods.GetDeviceCaps(hDc, NativeMethods.LOGPIXELSX);
- dpiy = NativeMethods.GetDeviceCaps(hDc, NativeMethods.LOGPIXELSY);
- NativeMethods.ReleaseDC(IntPtr.Zero, hDc);
+ var dpiXProperty = typeof(SystemParameters).GetProperty("DpiX", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
+ var dpiYProperty = typeof(SystemParameters).GetProperty("Dpi", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
+
+ dpix = (int)dpiXProperty.GetValue(null, null);
+ dpiy = (int)dpiYProperty.GetValue(null, null);
}
protected override void DestructRender()