Registry - How to rename key in registry using C++?

If your app requires Vista or newer versions of Windows, you can use RegCopyTree() followed by RegDeleteTree().


There is no function to rename on older versions of windows, you need to copy/delete on your own AFAIK.


Some more info on this old entry:

NTRenameKey() is an old API for renaming a registry key.

Also, Pavel has more information on the RegRenameKey() call mentioned in randomsock's answer, and (though this is a C++ question) provides this nice PInvoke signature for it.

[DllImport("advapi32")]
public static extern int RegRenameKey(
     SafeRegistryHandle hKey,
     [MarshalAs(UnmanagedType.LPWStr)] string oldname,
     [MarshalAs(UnmanagedType.LPWStr)] string newname);