C# 获取当前屏幕DPI
原文: C# 获取当前屏幕DPI 1.通过Graphics类获取 Graphics currentGraphics = Graphics.FromHwnd(new WindowInteropHelper(mainWindow).Handle); double dpixRatio = currentGraphics.DpiX/96; 比如当前屏幕设置DPI设置1.5倍,可以通过如上通过后台获取。 2.通过Win32-ManagementClass using (ManagementClass mc = new ManagementClass("Win32_DesktopMonitor")) { using (ManagementObjectCollection moc = mc.GetInstances()) { int PixelsPerXLogicalInch = 0; // dpi for x int PixelsPerYLogicalInch = 0; // dpi for y foreach (ManagementObject each in moc) { PixelsPerX...

