示例#1
0
        public static Dpi GetCurrentDpi()
        {
            Graphics g = Graphics.FromHwnd(IntPtr.Zero);
            IntPtr desktop = g.GetHdc();

            var dpi = new Dpi();
            dpi.HorizontalDpi = GetDeviceCaps(desktop, (int)DeviceCap.LOGPIXELSX);
            dpi.VerticalDpi = GetDeviceCaps(desktop, (int)DeviceCap.LOGPIXELSY);

            return dpi;
        }
示例#2
0
        public static Dpi GetCurrentDpi()
        {
            Graphics g       = Graphics.FromHwnd(IntPtr.Zero);
            IntPtr   desktop = g.GetHdc();

            var dpi = new Dpi();

            dpi.HorizontalDpi = GetDeviceCaps(desktop, (int)DeviceCap.LOGPIXELSX);
            dpi.VerticalDpi   = GetDeviceCaps(desktop, (int)DeviceCap.LOGPIXELSY);

            return(dpi);
        }