public static extern int EnumDisplaySettings(string lpszDeviceName, int iModeNum, ref DEVMODE lpDevMode);
 // helper for creating an initialized DEVMODE structure
 public static DEVMODE CreateDevmode(string deviceName)
 {
     var dm = new DEVMODE
     {
         dmDeviceName = new String(deviceName.ToCharArray()),
         dmFormName = new String(new char[32]),
         dmSize = (short) Marshal.SizeOf(typeof (DEVMODE))
     };
     return dm;
 }
 public static extern int ChangeDisplaySettingsEx(string lpszDeviceName, ref DEVMODE lpDevMode, IntPtr hwnd,
                                                  int dwflags, IntPtr lParam);
 public static extern int ChangeDisplaySettingsEx(string lpszDeviceName, ref DEVMODE lpDevMode, IntPtr hwnd,
     int dwflags, IntPtr lParam);
 public static extern int EnumDisplaySettings(string lpszDeviceName, int iModeNum, ref DEVMODE lpDevMode);