Using system.drawing; using system.collections; using system.windows.form; using system.data; using system.runtime.interopservices;
Namespace ScreenResolution {
Public class form1: system.windows.forms.form {public enum dmdo {default = 0, D90 = 1, D180 = 2, D270 = 3}
[StructLayout (LayoutKind.Sequential, CharSet = CharSet.Auto)] struct DEVMODE {public const int DM_DISPLAYFREQUENCY = 0x400000; public const int DM_PELSWIDTH = 0x80000; public const int DM_PELSHEIGHT = 0x100000; private const int CCHDEVICENAME = 32; private const int CCHFORMNAME = 32;
[MarshalAs (UnmanagedType.ByValTStr, SizeConst = CCHDEVICENAME)] public string dmDeviceName; public short dmSpecVersion; public short dmDriverVersion; public short dmSize; public short dmDriverExtra; public int dmFields;
Public int dmpositionx; public int dmpositiony; public dmdo dmdisplayorient; public int dmdisplayfixedoutput;
public short dmColor; public short dmDuplex; public short dmYResolution; public short dmTTOption; public short dmCollate; [MarshalAs (UnmanagedType.ByValTStr, SizeConst = CCHFORMNAME)] public string dmFormName; public short dmLogPixels; public int dmBitsPerPel; public int dmPelsWidth; public int dmPelsHeight; public int dmDisplayFlags; public int dmDisplayFrequency; public int dmICMMethod; public int dmICMIntent; public int dmMediaType; public int dmDitherType; public int dmReserved1; public int dmReserved2; public int dmPanningWidth; public int dmPanningHeight;} [DllImport ( "user32.dll ", CharSet = charset.auto] // static extern int changeisplaySettings (devmode lpdevmode, int dwflags);
static extern int ChangeDisplaySettings ([In] ref DEVMODE lpDevMode, int dwFlags); private System.ComponentModel.Container components = null; public Form1 () {InitializeComponent ();} protected override void Dispose (bool disposing) {if (disposing) { IF (Components! = null) {components.dispose ();}} Base.dispose (Disposing)
#region Windows Form Designer generated code private void InitializeComponent () {this.AutoScaleBaseSize = new System.Drawing.Size (6, 14); this.ClientSize = new System.Drawing.Size (292, 273); this.Text = " Change the example of the screen resolution ";
} #Endregion
Static void main () {form1 r = new form1 (); r.changeres (); application.run (new form1 ());}