Is it possible to get the DPI value of specific monitor?
I have tried all the methods that are online but they are always return the value of the primary monitor.
examples that i have used :
example1
using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
{
dpiX = g.DpiX;
dpiY = g.DpiY;
}
example2
PresentationSource source = PresentationSource.FromVisual(this);
double dpiX, dpiY;
if (source != null) {
dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;
}
example3
var dpiXProperty = typeof(SystemParameters).GetProperty("DpiX", BindingFlags.NonPublic | BindingFlags.Static);
var dpiYProperty = typeof(SystemParameters).GetProperty("Dpi", BindingFlags.NonPublic | BindingFlags.Static);
var dpiX = (int)dpiXProperty.GetValue(null, null);
var dpiY = (int)dpiYProperty.GetValue(null, null);
none of the above works for specific monitor