示例#1
0
        public static void ChangeResolution(ref DISPLAY_DEVICE device, int width, int height, short bits, int freq)
        {
            DEVMODE DevM       = CreateDevMode();
            bool    enumResult = false;
            DisplayChangeResultCode changeResult = default(DisplayChangeResultCode);

            DevM.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;

            enumResult = User32.EnumDisplaySettings(device.DeviceName, User32.ENUM_CURRENT_SETTINGS, ref DevM);

            DevM.dmPelsWidth        = width;
            DevM.dmPelsHeight       = height;
            DevM.dmBitsPerPel       = bits;
            DevM.dmDisplayFrequency = freq;

            DevM.dmDeviceName = device.DeviceName;

            changeResult = (DisplayChangeResultCode)User32.ChangeDisplaySettingsEx(device.DeviceName, ref DevM, IntPtr.Zero, (0), IntPtr.Zero);

            if (changeResult != DisplayChangeResultCode.DISP_CHANGE_SUCCESSFUL)
            {
                throw new User32Exception("Failed to change resolution: " + changeResult.ToString());
            }
        }
示例#2
0
 public static extern int ChangeDisplaySettingsEx(string lpDeviceName, ref DEVMODE lpDevMode, IntPtr HWND, int dwflags, IntPtr lParam);
示例#3
0
 public static extern bool EnumDisplaySettings(string lpszDeviceName, uint iModeNum, ref DEVMODE lpDevMode);
示例#4
0
 public static extern int ChangeDisplaySettings(ref DEVMODE lpDevMode, int dwFlags);
示例#5
0
 public DisplaySet(DISPLAY_DEVICE DisplayDevice, DEVMODE DeviceMode)
 {
     this.DisplayDevice = DisplayDevice;
     this.DeviceMode    = DeviceMode;
 }