ChangeDisplaySettingsA function (winuser.h)
The ChangeDisplaySettings function changes the settings of the default display device to the specified graphics mode.
To change the settings of a specified display device, use the ChangeDisplaySettingsEx function.
LONG ChangeDisplaySettingsA( [in] DEVMODEA *lpDevMode, [in] DWORD dwFlags );
A pointer to a DEVMODE structure that describes the new graphics mode. If lpDevMode is NULL, all the values currently in the registry will be used 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.
The dmSize member of DEVMODE must be initialized to the size, in bytes, of the DEVMODE structure. The dmDriverExtra member of DEVMODE must be initialized to indicate the number of bytes of private driver data following the DEVMODE structure. In addition, you can use any or all of the following members of the DEVMODE structure.
|dmBitsPerPel||Bits per pixel|
|dmPosition||Position of the device in a multi-monitor configuration.|
In addition to using one or more of the preceding DEVMODE members, you must also set one or more of the following values in the dmFields member to change the display setting.
|DM_BITSPERPEL||Use the dmBitsPerPel value.|
|DM_PELSWIDTH||Use the dmPelsWidth value.|
|DM_PELSHEIGHT||Use the dmPelsHeight value.|
|DM_DISPLAYFLAGS||Use the dmDisplayFlags value.|
|DM_DISPLAYFREQUENCY||Use the dmDisplayFrequency value.|
|DM_POSITION||Use the dmPosition value.|
Indicates how the graphics mode should be changed. This parameter can be one of the following values.
Specifying CDS_TEST allows an application to determine which graphics modes are actually valid, without causing the system to change to that graphics mode.
If CDS_UPDATEREGISTRY is specified and it is possible to change the graphics mode dynamically, the information is stored in the registry and DISP_CHANGE_SUCCESSFUL is returned. If it is not possible to change the graphics mode dynamically, the information is stored in the registry and DISP_CHANGE_RESTART is returned.
If CDS_UPDATEREGISTRY is specified and the information could not be stored in the registry, the graphics mode is not changed and DISP_CHANGE_NOTUPDATED is returned.
The ChangeDisplaySettings function returns one of the following values.
||The settings change was successful.|
||The settings change was unsuccessful because the system is DualView capable.|
||An invalid set of flags was passed in.|
||The graphics mode is not supported.|
||An invalid parameter was passed in. This can include an invalid flag or combination of flags.|
||The display driver failed the specified graphics mode.|
||Unable to write settings to the registry.|
||The computer must be restarted for the graphics mode to work.|
To ensure that the DEVMODE structure passed to ChangeDisplaySettings is valid and contains only values supported by the display driver, use the DEVMODE returned by the EnumDisplaySettings function.
When the display mode is changed dynamically, the WM_DISPLAYCHANGE message is sent to all running applications with the following message parameters.
|wParam||New bits per pixel|
|LOWORD(lParam)||New pixel width|
|HIWORD(lParam)||New pixel height|
DPI VirtualizationThis API does not participate in DPI virtualization. The input given is always in terms of physical pixels, and is not related to the calling context.
The winuser.h header defines ChangeDisplaySettings as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
|Minimum supported client||Windows 2000 Professional [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|
|Header||winuser.h (include Windows.h)|
|API set||ext-ms-win-ntuser-sysparams-ext-l1-1-1 (introduced in Windows 10, version 10.0.14393)|