HKEY hKey;
DWORD value = 0; DWORD type = 0; DWORD size = 0;
if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, _T("ControlPanelBackLight"), 0, 0, &hKey)) { value = 0; type = REG_DWORD; size = sizeof(DWORD);
// change the reg keys for AC power RegSetValueEx(hKey, _T("UseExt"), 0, REG_DWORD, (BYTE*)&value, sizeof(DWORD)); RegQueryValueEx(hKey, _T("ACTimeout"), 0, &type, (BYTE*)&value, &size); RegSetValueEx(hKey, _T("OldACTimeout"), 0, REG_DWORD, (BYTE*)&value, sizeof(DWORD)); RegDeleteValue(hKey, _T("ACTimeout"));
// change the reg keys for Battery power value = 0; RegSetValueEx(hKey, _T("UseBattery"), 0, REG_DWORD, (BYTE*)&value, sizeof(DWORD)); RegQueryValueEx(hKey, _T("BatteryTimeout"), 0, &type, (BYTE*)&value, &size); RegSetValueEx(hKey, _T("OldBatteryTimeout"), 0, REG_DWORD, (BYTE*)&value, sizeof(DWORD)); RegDeleteValue(hKey, _T("BatteryTimeout"));
RegCloseKey(hKey);
// notify the driver we've made changes HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, _T("BackLightChangeEvent")); if(hEvent) { SetEvent(hEvent); CloseHandle(hEvent); } } |