MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / RenameValue

Method RenameValue

WinArk/Registry.cpp:364–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362}
363
364bool 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
385bool Registry::CopyKey(HKEY hKey, PCWSTR path, HKEY hTarget) {
386 auto error = ::RegCopyTree(hKey, path, hTarget);

Callers

nothing calls this directly

Calls 4

QueryValueMethod · 0.80
DeleteValueMethod · 0.80
OpenMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected