The ChangeDisplaySettingsEx function changes the settings of the display device specified in the lpszDeviceName parameter to the graphics mode specified in the lpDevMode parameter.
Declare Function ChangeDisplaySettingsEx Lib "user32" Alias "ChangeDisplaySettingsExA" (lpszDeviceName As Any, lpDevMode As Any, ByVal hWnd As Long, ByVal dwFlags As Long, lParam As Any) As Long
|Operating Systems Supported|
|Requires Windows 2000 or later; Requires Windows 98 or later|
[in] Pointer to a null-terminated string that specifies the display device whose graphics mode the function will obtain information about. Only display device names as returned by EnumDisplayDevices are valid. See EnumDisplayDevices for further information on the names associated with these display devices.
The lpszDeviceName parameter can be NULL. A NULL value specifies the default display device. The default device can be determined by calling EnumDisplayDevices and checking for the DISPLAY_DEVICE_PRIMARY_DEVICE flag.
[in] 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 must be initialized to the size, in bytes, of the DEVMODE structure. The dmDriverExtra member must be initialized to indicate the number of bytes of private driver data following the DEVMODE structure. In addition, you can use any of the following members of the DEVMODE structure.
Bits per pixel
Windows 98, Windows 2000: 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 settings.
Use the dmBitsPerPel value.
Use the dmPelsWidth value.
Use the dmPelsHeight value.
Use the dmDisplayFlags value.
Use the dmDisplayFrequency value.
Windows 98, Windows 2000: Use the dmPosition value.
Reserved; must be NULL.
[in] Indicates how the graphics mode should be changed. This parameter can be one of the following values.
The graphics mode for the current screen will be changed dynamically.
The mode is temporary in nature.
Windows NT/2000: If you change to and from another desktop, this mode will not be reset.
The settings will be saved in the global settings area so that they will affect all users on the machine. Otherwise, only the settings for the user are modified. This flag is only valid when specified with the CDS_UPDATEREGISTRY flag.
The settings will be saved in the registry, but will not take effect. This flag is only valid when specified with the CDS_UPDATEREGISTRY flag.
The settings should be changed, even if the requested settings are the same as the current settings.
This device will become the primary device.
The system tests if the requested graphics mode could be set.
The graphics mode for the current screen will be changed dynamically and the graphics mode will be updated in the registry. The mode information is stored in the USER profile.
Windows NT/2000: When set, the lParam parameter is a pointer to a VIDEOPARAMETERS structure.
Specifying CDS_TEST allows an application to determine which graphics modes are actually valid, without causing the system to change to them.
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.
Windows NT/2000: 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.
Windows NT/2000: [in] If dwFlags is CDS_VIDEOPARAMETERS, lParam is a pointer to a VIDEOPARAMETERS structure. Otherwise lParam must be NULL.
|The ChangeDisplaySettingsEx function returns one of the following values.|
DISP_CHANGE_BADFLAGS An invalid set of flags was passed in.
DISP_CHANGE_BADMODE The graphics mode is not supported.
DISP_CHANGE_BADPARAM An invalid parameter was passed in. This can include an invalid flag or combination of flags.
DISP_CHANGE_FAILED The display driver failed the specified graphics mode.
DISP_CHANGE_NOTUPDATED Windows NT/2000: Unable to write settings to the registry.
DISP_CHANGE_RESTART The computer must be restarted for the graphics mode to work.
DISP_CHANGE_SUCCESSFUL The settings change was successful.