{"record":{"id":"031865be0fbcb032","repo":"ramensoftware/windhawk","slug":"unsupported-registrykey-value","errorCode":null,"errorMessage":"Unsupported RegistryKey value","messagePattern":"Unsupported RegistryKey value","errorType":"exception","errorClass":"std::runtime_error","httpStatus":null,"severity":"error","filePath":"src/windhawk/app/storage_manager.cpp","lineNumber":251,"sourceCode":"            throw std::runtime_error(\"Missing RegistryKey value\");\n        }\n\n        auto firstBackslash = registryKey.find(L'\\\\');\n        if (firstBackslash == registryKey.npos) {\n            throw std::runtime_error(\"Invalid RegistryKey value\");\n        }\n\n        HKEY hkey;\n\n        std::wstring baseKey = registryKey.substr(0, firstBackslash);\n        if (baseKey == L\"HKEY_CURRENT_USER\" || baseKey == L\"HKCU\") {\n            hkey = HKEY_CURRENT_USER;\n        } else if (baseKey == L\"HKEY_USERS\" || baseKey == L\"HKU\") {\n            hkey = HKEY_USERS;\n        } else if (baseKey == L\"HKEY_LOCAL_MACHINE\" || baseKey == L\"HKLM\") {\n            hkey = HKEY_LOCAL_MACHINE;\n        } else {\n            throw std::runtime_error(\"Unsupported RegistryKey value\");\n        }\n\n        std::wstring subKey = registryKey.substr(firstBackslash + 1);\n\n        settingsPath = RegistryPath{hkey, std::move(subKey)};\n    }\n}\n\nStorageManager::~StorageManager() = default;\n","sourceCodeStart":233,"sourceCodeEnd":261,"githubUrl":"https://github.com/ramensoftware/windhawk/blob/61d99ed8e182e1af1b60109612b6763ad1b4b74e/src/windhawk/app/storage_manager.cpp#L233-L261","documentation":"The base-key portion of the RegistryKey value must be one of the supported hives: HKEY_CURRENT_USER/HKCU, HKEY_USERS/HKU, or HKEY_LOCAL_MACHINE/HKLM. Any other base key name is rejected at StorageManager construction because the code cannot map it to an HKEY.","triggerScenarios":"StorageManager constructor sees a RegistryKey whose text before the first backslash is not one of the six accepted hive aliases — e.g. \"HKEY_CLASSES_ROOT\\...\" or a misspelled hive.","commonSituations":"Typo in the hive name (HKCU vs HKCU-Users); attempting to point settings at an unsupported hive like HKEY_CLASSES_ROOT; copy-pasting a full registry path with extra prefix.","solutions":["Use a supported hive prefix: HKEY_CURRENT_USER (HKCU), HKEY_USERS (HKU), or HKEY_LOCAL_MACHINE (HKLM)","Fix the spelling/casing of the base key in the RegistryKey value","Pick a hive that matches the deployment (HKCU for per-user, HKLM for machine-wide)"],"exampleFix":"// before\n\"RegistryKey\": \"HKEY_CLASSES_ROOT\\Software\\Windhawk\"\n// after\n\"RegistryKey\": \"HKEY_CURRENT_USER\\Software\\Windhawk\"","handlingStrategy":"validation","validationCode":"static const std::wstring hives[] = {L\"HKEY_CURRENT_USER\", L\"HKCU\", L\"HKEY_USERS\", L\"HKU\", L\"HKEY_LOCAL_MACHINE\", L\"HKLM\"};\nstd::wstring base = key.substr(0, key.find(L'\\\\'));\nbool ok = std::find(std::begin(hives), std::end(hives), base) != std::end(hives);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only HKCU, HKU, or HKLM as the settings hive","Fix hive-name typos before writing the value","Prefer the installer-managed value over manual composition"],"tags":["registry","config","cpp","windows"],"backgroundTag":"invalid-enum-value","analyzedSha":"61d99ed8e182e1af1b60109612b6763ad1b4b74e","analyzedAt":"2026-09-12T14:02:41.115Z","contentChangedAt":"2026-09-12T14:02:41.115Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}