public static Monitor[] GetMonitors() { List <Monitor> monitors = new List <Monitor>(); Int32 id = 0; foreach (Screen screen in Screen.AllScreens) { DEVMODE dm = new DEVMODE { dmSize = (Int16)Marshal.SizeOf(typeof(DEVMODE)) }; EnumDisplaySettings(screen.DeviceName, EnumCurrentSettings, ref dm); monitors.Add(new Monitor(id++, screen.DeviceName, screen.Bounds, screen.WorkingArea, screen.Bounds, dm.dmDisplayFrequency)); } return(monitors.ToArray()); }
public static extern int ChangeDisplaySettings( ref DEVMODE devMode, int flags);
public static extern int EnumDisplaySettings( string deviceName, int modeNum, ref DEVMODE devMode);
public static extern int ChangeDisplaySettingsEx(string lpszDeviceName, ref DEVMODE lpDevMode, IntPtr hwnd, uint dwflags, IntPtr lParam);
private static extern Boolean EnumDisplaySettings(String lpszDeviceName, Int32 iModeNum, ref DEVMODE lpDevMode);