Tente contornar com WinAPI. Primeiro, terá que adicionar essas referências:
using System.Drawing;
using System.Windows.Forms;
É possível obter o DPI de todos os monitores instalados com chamadas da GetDpiForMonitor
:
public static class ScreenExtensions
{
public static void GetDpi(this System.Windows.Forms.Screen screen, DpiType dpiType, out uint dpiX, out uint dpiY)
{
var pnt = new System.Drawing.Point(screen.Bounds.Left + 1, screen.Bounds.Top + 1);
var mon = MonitorFromPoint(pnt, 2/*MONITOR_DEFAULTTONEAREST*/);
GetDpiForMonitor(mon, dpiType, out dpiX, out dpiY);
}
//https://msdn.microsoft.com/en-us/library/windows/desktop/dd145062(v=vs.85).aspx
[DllImport("User32.dll")]
private static extern IntPtr MonitorFromPoint([In]System.Drawing.Point pt, [In]uint dwFlags);
//https://msdn.microsoft.com/en-us/library/windows/desktop/dn280510(v=vs.85).aspx
[DllImport("Shcore.dll")]
private static extern IntPtr GetDpiForMonitor([In]IntPtr hmonitor, [In]DpiType dpiType, [Out]out uint dpiX, [Out]out uint dpiY);
}
//https://msdn.microsoft.com/en-us/library/windows/desktop/dn280511(v=vs.85).aspx
public enum DpiType
{
Effective = 0,
Angular = 1,
Raw = 2,
}
Nota rápida: Funciona apenas com Windows 8+.
Existem três meios de escala, olhe a documentação para saber mais.
É bem fácil emular o código em um console:
private IEnumerable<string> Display(DpiType type)
{
foreach (var screen in System.Windows.Forms.Screen.AllScreens)
{
uint x, y;
screen.GetDpi(type, out x, out y);
yield return screen.DeviceName + " - dpiX=" + x + ", dpiY=" + y;
}
}
void Main(string[] args)
{
Console.WriteLine(string.Join("\n", Display(DpiType.Angular)));
Console.WriteLine(string.Join("\n", Display(DpiType.Effective)));
Console.WriteLine(string.Join("\n", Display(DpiType.Raw)));
// pausa a execução
Console.ReadLine();
}
Peguei a resposta daqui.