Appccelerate.Windows.GraphicHelper.GetDpi C# (CSharp) Method

GetDpi() public static method

Calculates the DPI of the windows desktop.
public static GetDpi ( ) : int
return int
        public static int GetDpi()
        {
            IntPtr dPC = NativeMethods.GetDC(NativeMethods.GetDesktopWindow());
            int dpi = NativeMethods.GetDeviceCaps(dPC, 88);
            NativeMethods.ReleaseDC(NativeMethods.GetDesktopWindow(), dPC);
            return dpi;
        }

Usage Example

        public void GetDpi()
        {
            int dpi = GraphicHelper.GetDpi();

            dpi.Should().BeGreaterThan(0);
        }
GraphicHelper