public static string DevmodeToString(Devmode devMode) { return(devMode.DMPelsWidth + " x " + devMode.DMPelsHeight + ", " + devMode.DMBitsPerPel + " bits, " + devMode.DMDisplayFrequency + " Hz"); }
public static Devmode GetDevmode(int devNum, int modeNum) { var devMode = new Devmode(); var devName = GetDeviceName(devNum); NativeMethods.EnumDisplaySettings(devName, modeNum, ref devMode); return(devMode); }
public static void ChangeResolutionMode(int devNum, Devmode mode) { if (mode.DMBitsPerPel != 0 && mode.DMPelsWidth != 0 && mode.DMPelsHeight != 0) { var result = NativeMethods.ChangeDisplaySettingsEx(GetDeviceName(devNum), ref mode, IntPtr.Zero, 0, IntPtr.Zero); if (result > 0) { return; } } }
public static Devmode[] EnumModes(int devNum) { var modes = new ArrayList(); var devName = GetDeviceName(devNum); var devMode = new Devmode(); var modeNum = 0; bool result; do { result = NativeMethods.EnumDisplaySettings(devName, modeNum, ref devMode); if (result) { modes.Add(devMode); } modeNum++; } while (result); return((Devmode[])modes.ToArray(typeof(Devmode))); }
public static extern int ChangeDisplaySettingsEx( string devName, ref Devmode devMode, IntPtr hwnd, int dwFlags, IntPtr lParam);
public static extern bool EnumDisplaySettings( string devName, int modeNum, ref Devmode devMode);
public ScreenRes(Devmode mode) { Mode = mode; }