public static Int32 PixelsPerInch(Orientation orientation) { Int32 capIndex = (orientation == Orientation.Horizontal) ? 0x58 : 90; using (DCSafeHandle handle = UnsafeNativeMethods.CreateDC("DISPLAY")) { return(handle.IsInvalid ? 0x60 : UnsafeNativeMethods.GetDeviceCaps(handle, capIndex)); } }
internal static int PixelsPerInch(Orientation orientation) { int nIndex = (orientation == Orientation.Horizontal ? NativeMethods.LOGPIXELSX : NativeMethods.LOGPIXELSY); using (DCSafeHandle screenDC = UnsafeNativeMethods.CreateDC(DISPLAY)) { return(screenDC.IsInvalid ? defaultPixelsPerInch : UnsafeNativeMethods.GetDeviceCaps(screenDC, nIndex)); } }
public static extern Int32 GetDeviceCaps(DCSafeHandle hDC, Int32 nIndex);