| 34 | } |
| 35 | |
| 36 | winreg::RegKey getOrCreateAlienRegKey() |
| 37 | { |
| 38 | const std::wstring testSubKey = L"SOFTWARE\\alien"; |
| 39 | winreg::RegKey key{HKEY_CURRENT_USER, testSubKey}; |
| 40 | if (key.TryOpen(HKEY_CURRENT_USER, testSubKey)) { |
| 41 | return key; |
| 42 | } else { |
| 43 | auto result = key.TryCreate(HKEY_CURRENT_USER, testSubKey); |
| 44 | if (result.IsOk()) { |
| 45 | if (key.TryOpen(HKEY_CURRENT_USER, testSubKey)) { |
| 46 | return key; |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | throw std::runtime_error("Could not open a registry key."); |
| 51 | } |
| 52 | |
| 53 | std::string getStringFromWinReg(std::string const& name, std::string const& defaultValue) |
| 54 | { |
no test coverage detected