private static float GetDpi(GetDeviceCapsIndex index) { IntPtr desktopWnd = IntPtr.Zero; IntPtr dc = GetDC(desktopWnd); float dpi; try { dpi = GetDeviceCaps(dc, (int)index); } finally { ReleaseDC(desktopWnd, dc); } return(dpi / 96f); }
public static extern int GetDeviceCaps(IntPtr hdc, GetDeviceCapsIndex nIndex);
public static extern int GetDeviceCaps([In] IntPtr hdc, [In] GetDeviceCapsIndex capIndex);