// helper for creating an initialized DEVMODE structure
 public static DEVMODE CreateDevmode()
 {
     DEVMODE dm = new DEVMODE();
     dm.dmDeviceName = new String(new char[32]);
     dm.dmFormName = new String(new char[32]);
     dm.dmSize = (short)Marshal.SizeOf(dm);
     return dm;
 }
 public static extern int EnumDisplaySettings(string lpszDeviceName, int iModeNum, ref DEVMODE lpDevMode);
 public static extern int ChangeDisplaySettings(ref DEVMODE lpDevMode, int dwFlags);