| 362 | } |
| 363 | |
| 364 | bool Registry::RenameValue(HKEY hKey, PCWSTR path, PCWSTR oldName, PCWSTR newName) { |
| 365 | CRegKey key; |
| 366 | key.Open(hKey, path, KEY_QUERY_VALUE | KEY_SET_VALUE); |
| 367 | if (!key) |
| 368 | return false; |
| 369 | |
| 370 | DWORD bytes = 0; |
| 371 | DWORD type; |
| 372 | key.QueryValue(oldName, &type, nullptr, &bytes); |
| 373 | if (bytes == 0) |
| 374 | return false; |
| 375 | |
| 376 | auto buffer = std::make_unique<BYTE[]>(bytes); |
| 377 | if (ERROR_SUCCESS != key.QueryValue(oldName, &type, buffer.get(), &bytes)) |
| 378 | return false; |
| 379 | if (ERROR_SUCCESS != key.SetValue(newName, type, buffer.get(), bytes)) |
| 380 | return false; |
| 381 | |
| 382 | return ERROR_SUCCESS == key.DeleteValue(oldName); |
| 383 | } |
| 384 | |
| 385 | bool Registry::CopyKey(HKEY hKey, PCWSTR path, HKEY hTarget) { |
| 386 | auto error = ::RegCopyTree(hKey, path, hTarget); |
nothing calls this directly
no test coverage detected