<DllImport("user32.dll")> _
Private Shared Function ChangeDisplaySettingsEx(ByVal lpszDeviceName As String, ByRef lpDevMode As DEVMODE, ByVal hwnd As IntPtr, ByVal dwflags As UInteger, ByVal lParam As IntPtr) As DISP_CHANGE
End Function
DISPLAY_DEVICE d = new DISPLAY_DEVICE();
DEVMODE dm = new DEVMODE();
d.cb = Marshal.SizeOf(d);
int deviceID=1; // This is only for my device setting. Go through the whole EnumDisplayDevices to find your device
EnumDisplayDevices(null,deviceID, ref d, 0); //
EnumDisplaySettings(d.DeviceName, 0, ref dm);
dm.dmPelsWidth = 1024;
dm.dmPelsHeight = 768;
dm.dmPositionX = Screen.PrimaryScreen.Bounds.Right;
dm.dmFields = DM.Position | DM.PelsWidth | DM.PelsHeight;
ChangeDisplaySettingsEx(d.DeviceName, ref dm, IntPtr.Zero, CDS_UPDATEREGISTRY, IntPtr.Zero);
Alternative Managed API:
Do you know one? Please contribute it!
Return values for ChangeDisplaySettings and ChangeDisplaySettingsEx
3/25/2011 5:36:01 PM - -12.24.60.12
Contains information about the initialization and environment of a printer or a display device.
10/5/2012 4:32:52 PM - -109.192.0.91
Changes the display settings via a DEVMODE struct.
5/3/2012 10:17:38 PM - -12.107.192.178
TODO - a short description
4/1/2011 9:14:59 PM - -200.60.95.194
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).