A version of this page is also available for

Windows Embedded CE 6.0 R3


This function changes the settings of the specified display device to the specified graphics mode.


LONG ChangeDisplaySettingsEx(
  LPCTSTR lpszDeviceName,
  LPDEVMODE lpDevMode,
  HWND hwnd,
  DWORD dwflags,
  LPVOID lParam


  • lpszDeviceName
    [in] Not used. Set to NULL.
  • lpDevMode
    [in, out] Pointer to a DEVMODE structure that describes the new graphics mode.

    If lpDevMode is NULL, ChangeDisplaySettingsEx uses all of the values currently in the registry for the display setting.

    Passing NULL for the lpDevMode parameter and 0 for the dwFlags parameter is the easiest way to return to the default mode after a dynamic mode change.

    You must initialize the dmSize member of the DEVMODE structure with the size, in bytes, of the structure. The following table shows the members of the DEVMODE structure that you can use.

    Value Description


    Screen rotation.

    Setting the dmBitsPerPel member is not supported.

    The following table shows the values in the dmFields member that you must also set to change the display settings, in addition to using one or more of the preceding DEVMODE members.

    Value Description


    Check whether the display driver supports screen rotation.

    The supported screen orientations are returned in lpDevMode.dmDisplayOrientation.

    A value of just DMO_0 indicates that screen rotation is not supported.


    Use the dmDisplayOrientation value to change the orientation of the screen.

    To ensure that the DEVMODE structure passed to ChangeDisplaySettingsEx is valid and contains only values supported by the display driver, use the DEVMODE returned by the EnumDisplaySettings function.

  • hwnd
    [in] Reserved; must be NULL.
  • dwflags
    [in] DWORD that indicates how you want to change the graphics mode. The following table shows the possible values.

    Value Description


    Changes the graphics mode for the current screen dynamically.


    Changes the settings even if the requested settings are the same as the current settings.


    Tests if ChangeDisplaySettingsEx can set the requested graphics mode.

    Specifying CDS_TEST allows an application to determine which graphics modes are actually valid, without causing the system to change to the settings.


    Indicates that the lParam parameter is a pointer to a VIDEOPARAMETERS structure.

  • lParam
    [in] Pointer to a VIDEOPARAMETERS structure if dwFlags is CDS_VIDEOPARAMETERS. Otherwise, set to NULL.

Return Value

The following table shows the possible return values.

Value Description


The settings change was successful.


An invalid set of values was used in the dwFlags parameter.


The graphics mode is not supported.


An invalid parameter was used.

This error can include an invalid value or combination of values.


The display driver failed the specified graphics mode.


ChangeDisplaySettingsEx was unable to write settings to the registry.


The user must restart the computer for the graphics mode to work.


When you change the display mode dynamically, the OS sends the WM_SETTINGCHANGE message to all running applications.

To query for the current orientation, call ChangeDisplaySettingsEx with lpDevMode set to DM_DISPLAYORIENTATION and dwflags set to CDS_TEST. The current orientation will be returned in lpDevMode.

The following table shows the value of the parameters that the OS uses when it sends this message.

Parameter Value





Using the dmFields flag of DM_DISPLAYORIENTATION, ChangeDisplaySettingsEx can be used to dynamically rotate the screen orientation. For operating systems based on Windows CE 5.0 and earlier versions, the DM_PELSWIDTH and DM_PELSHEIGHT flags cannot be used to change the screen resolution.


Header windows.h
Library coredll.lib
Windows Embedded CE Windows CE .NET 4.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also