Replaces the file backing a registry key and all its subkeys with another file, so that when the system is next started, the key and subkeys will have the values stored in the new file.
Applications that back up or restore system state including system files and registry hives should use the Volume Shadow Copy Service instead of the registry functions.
LSTATUS RegReplaceKeyA( HKEY hKey, LPCSTR lpSubKey, LPCSTR lpNewFile, LPCSTR lpOldFile );
HKEY_CLASSES_ROOT HKEY_CURRENT_CONFIG HKEY_CURRENT_USER HKEY_LOCAL_MACHINE HKEY_USERS
The name of the registry key whose subkeys and values are to be replaced. If the key exists, it must be a subkey of the key identified by the hKey parameter. If the subkey does not exist, it is created. This parameter can be NULL.
If the specified subkey is not the root of a hive, RegReplaceKey traverses up the hive tree structure until it encounters a hive root, then it replaces the contents of that hive with the contents of the data file specified by lpNewFile.
For more information, see Registry Element Size Limits.
The name of the file with the registry information. This file is typically created by using the RegSaveKey function.
The name of the file that receives a backup copy of the registry information being replaced.
If the function succeeds, the return value is ERROR_SUCCESS.
If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.
There are two different registry hive file formats. Registry hives created on current operating systems typically cannot be loaded by earlier ones.
The file specified by the lpNewFile parameter remains open until the system is restarted.
If hKey is a handle returned by RegConnectRegistry, then the paths specified in lpNewFile and lpOldFile are relative to the remote computer.
The calling process must have the SE_RESTORE_NAME and SE_BACKUP_NAME privileges on the computer in which the registry resides. For more information, see Running with Special Privileges.
|Minimum supported client||Windows 2000 Professional [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|
|Header||winreg.h (include Windows.h)|