Article ID: 308216
On a Windows 2000 or Windows XP-based system, when you use the ChangeDisplaySettingsEx function to attach a secondary monitor to the desktop, the change does not take effect until you restart the computer.
This problem occurs on multiple-monitor portable computers that use a dual-view implementation, with which you can use both an external CRT display and the built-in LCD display.
To resolve this problem, call ChangeDisplaySettings(NULL, 0) to update the desktop immediately after you call ChangeDisplaySettingsEx to attach the secondary monitor to the desktop. This causes the system to use the settings in the registry and resets each of the display devices.
The following code attaches the first secondary device that it finds to the desktop without requiring you to restart the computer: