RegReplaceKey

  LONG RegReplaceKey(hKey, lpSubKey, lpNewFile, lpOldFile)    
  HKEY hKey;    
  LPTSTR lpSubKey;    
  LPTSTR lpNewFile;    
  LPTSTR lpOldFile;    

Replace an existing tree (hive) in the registry. The new tree will take effect the next time the system is rebooted.

Parameters

hKey

Specifies a handle to an open key. lpSubKey is relative to this handle.

lpSubKey

Supplies a path name to the key that is to be replaced. The combination of hKey and lpSubKey must refer to a hive in the registry. This parameter may be NULL.

lpNewFile

Supplies a file name for the new hive file.

lpOldFile

Supplies a backup file name for the old (existing) hive file.

Return Value

If the function is successful, the return value is ERROR_SUCCESS. Otherwise, it is an error code.

Comments

lpNewFile will remain open until after the system is rebooted.

RegReplaceKey requires SeRestorePrivilege.