if (AccelLevel != AccelLevelInReg)
{
//
// Popup the dialog to ask user to apply it dynamically or not.
//
int val = GetDynaCDSPreference();
BOOL bSuccess = TRUE;
if (val & DCDSF_ASK)
{
switch (DialogBoxParam(g_hInst,
MAKEINTRESOURCE(DLG_ASKDYNACDS),
hDlg,
AskDynamicApply,
(LPARAM)&val))
{
case 0: // user cancelled
case -1: // dialog could not be displayed
bSuccess = FALSE;
break;
}
}
if (bSuccess)
{
//
// AccelLevel has been changed. save it to registry.
//
HKEY hKeyAccelLevel;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
gszRegistryPath,
0,
KEY_ALL_ACCESS,
&hKeyAccelLevel) == ERROR_SUCCESS)
{
if (AccelLevel == ACCELERATION_FULL)
{
//
// If acceration is set to ACCELERATION_FULL (default)
// remove registry value.
//
if (RegDeleteValue(hKeyAccelLevel,
SZ_ACCELLEVEL) == ERROR_SUCCESS)
{
bSuccess = TRUE;
}
}
else
{
//
// Otherwise, save it to registry.
//
if (((val & DCDSF_DYNA) == DCDSF_DYNA))
{
// Apply it dynamically.
// If EnumDisplaySettings was called with EDS_RAWMODE, we need CDS_RAWMODE below.
// Otherwise, it's harmless.
ChangeDisplaySettings(NULL, CDS_RAWMODE);
}
else
{
// User wants to reboot system.