Пример #1
0
        /// <summary>
        /// 修改屏幕分辨
        /// </summary>
        /// <param name="i"></param>
        public static Boolean ChangeScreen(int width, int height)
        {
            DEVMODE dm = new DEVMODE();

            dm.dmDeviceName = new string(new char[32]);
            dm.dmFormName   = new string(new char[32]);
            dm.dmSize       = (short)Marshal.SizeOf(dm);
            if (0 != EnumDisplaySettings(null, ENUM_CURRENT_SETTINGS, ref dm))
            {
                if (dm.dmPelsHeight == height && dm.dmPelsWidth == width)
                {
                    return(false);
                }
                dm.dmPelsHeight = height;
                dm.dmPelsWidth  = width;

                int iRet = ChangeDisplaySettings(ref dm, 0);
                return(true);
            }
            return(false);
        }
Пример #2
0
 public static extern int ChangeDisplaySettings(ref DEVMODE lpDevMode, int dwFlags);
Пример #3
0
 public static extern int ChangeDisplaySettingsEx(string lpszDeviceName, ref DEVMODE lpDevMode, IntPtr hwnd, int dwflags, IntPtr lParam);
Пример #4
0
 public static extern int EnumDisplaySettings(string lpszDeviceName, int iModeNum, ref DEVMODE lpDevMode);
Пример #5
0
        private static void CommitChange(Screen screen)
        {
            DEVMODE ndm5 = CreateDevmode();

            ChangeDisplaySettingsEx(screen.DeviceName, ref ndm5, (IntPtr)null, (int)(DeviceFlags.CDS_UPDATEREGISTRY), (IntPtr)null);
        }