Example #1
0
        public static void SetDisplayMode(string deviceName, DisplayMode displayMode)
        {
            DevMode devMode = new DevMode();

            devMode.dmSize             = (short)Marshal.SizeOf(devMode);
            devMode.dmBitsPerPel       = displayMode.BitsPerPixels;
            devMode.dmPelsWidth        = displayMode.Width;
            devMode.dmPelsHeight       = displayMode.Height;
            devMode.dmDisplayFrequency = displayMode.Frequency;
            devMode.dmFields           = DM.BitsPerPixel | DM.DisplayFrequency | DM.PelsHeight | DM.PelsWidth;

            DisplayChange result = User32.ChangeDisplaySettingsEx(deviceName, ref devMode, IntPtr.Zero, ChangeDisplaySettingsFlags.FullScreen, IntPtr.Zero);
        }
Example #2
0
 public static void ResetDisplayMode(string deviceName)
 {
     DisplayChange result = User32.ChangeDisplaySettingsEx(deviceName, IntPtr.Zero, IntPtr.Zero, ChangeDisplaySettingsFlags.None, IntPtr.Zero);
 }