diff --git a/.gitignore b/.gitignore index f552cdd..1ca0f39 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ obj *.layout *.bak *.zip +.vscode \ No newline at end of file diff --git a/persistent.cpp b/persistent.cpp index e79ac54..4b4d878 100644 --- a/persistent.cpp +++ b/persistent.cpp @@ -220,12 +220,14 @@ PersistentSystemOptions PersistentSystemOptions::ReadSystemSettings() std::string system = "\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; std::string explorer = "\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"; std::string power = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power"; + std::string only_system = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; + PersistentSystemOptions retval; retval.hasChangePassword = !ReadRegistryKey(HKEY_USERS, _T(sid + system), _T("DisableChangePassword"), false); retval.hasLockComputer = !ReadRegistryKey(HKEY_USERS, _T(sid + system), _T("DisableLockWorkstation"), false); retval.hasLogOff = !ReadRegistryKey(HKEY_USERS, _T(sid + explorer), _T("NoLogoff"), false); - retval.hasSwitchUser = !ReadRegistryKey(HKEY_LOCAL_MACHINE, _T(sid + system), _T("HideFastUserSwitching"), false); + retval.hasSwitchUser = !ReadRegistryKey(HKEY_LOCAL_MACHINE, _T(only_system), _T("HideFastUserSwitching"), false); retval.hasTaskManager = !ReadRegistryKey(HKEY_USERS, _T(sid + system), _T("DisableTaskMgr"), false); retval.hasPower = !ReadRegistryKey(HKEY_USERS, _T(sid + explorer), _T("NoClose"), false); retval.hasFilterKeysHotkey = ReadFilterKeysHotkey(); @@ -233,7 +235,7 @@ PersistentSystemOptions PersistentSystemOptions::ReadSystemSettings() retval.hasStickyKeysHotkey = ReadStickyKeysHotkey(); retval.hasToggleKeysHotkey = ReadToggleKeysHotkey(); retval.hasHighContrastHotkey = ReadHighContrastHotkey(); - retval.hasFastBootHotKey = !ReadRegistryKey(HKEY_LOCAL_MACHINE, _T(sid + power), _T("HiberbootEnabled"), false); + retval.hasFastBootHotKey = !ReadRegistryKey(HKEY_LOCAL_MACHINE, _T(power), _T("HiberbootEnabled"), false); return retval; } @@ -242,6 +244,7 @@ bool PersistentSystemOptions::WriteSystemSettings() const bool allWorked = true; char* sid = getSid(); std::string system = "\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; + std::string only_system = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; std::string explorer = "\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"; std::string power = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power"; @@ -255,6 +258,11 @@ bool PersistentSystemOptions::WriteSystemSettings() const Tcout << _T("Error NoLogoff") << std::endl; } + if(!WriteRegistryKey(HKEY_LOCAL_MACHINE, _T(only_system), _T("HideFastUserSwitching"), !hasSwitchUser)) { + allWorked = false; + Tcout << _T("Error HideFastUserSwitching") << std::endl; + } + #ifndef DEBUG if(!WriteRegistryKey(HKEY_USERS, _T(sid + system), _T("DisableTaskMgr"), !hasTaskManager)) { @@ -294,6 +302,11 @@ bool PersistentSystemOptions::WriteSystemSettings() const Tcout << _T("Error HighContrastHotkey") << std::endl; } + /* if(!WriteRegistryKey(HKEY_LOCAL_MACHINE, _T(power), _T("HiberbootEnabled"), hasFastBootHotKey)) { + allWorked = false; + Tcout << _T("Error FastBootHotKey") << std::endl; + } */ + return allWorked; }