RegRestoreKey

  LONG RegRestoreKey(hkey, lpszFile, fdw)    
  HKEY hkey; /* key where restore begins */
  LPTSTR lpszFile; /* name of file containing saved tree */
  DWORD fdw; /* optional flags */

The RegRestoreKey function writes the tree in the specified file onto the key referenced by hkey. The new tree overwrites the contents of the tree under hkey.

Parameters

hkey

Identifies the key where the file is to be restored, either a currently open key or any of the following predefined reserved handle values:

HKEY_CLASSES_ROOT HKEY_CURRENT_USER HKEY_LOCAL_MACHINE HKEY_USERS

lpszFile

Points to a null-terminated string that specifies the the name of a file whose contents were created with the RegSaveKey function.

fdw

Specifies optional flags. Currently, this parameter can have the following value:

Value Meaning

REG_WHOLE_HIVE_VOLATILE  
  Instead of restoring the specified key, this flag causes a new, volatile (memory only) hive to be created.
  If this flag is specified, hkey must be either HKEY_USERS or HKEY_LOCAL_MACHINE.

Return Value

The return value is ERROR_SUCCESS if the function is successful. Otherwise, it is an error value.

Comments

If the calling process does not have SeRestorePrivilege, this function will fail.

If any subkeys of hkey are open, this function will fail.

This function replaces the tree below the specified registration key. If the existing tree has the following form:

A

/ \

/ \

B C

And the contents of the file have the following form:

X

/ \

/ \

Q R

If hkey specifies key A, the result of the RegRestoreKey function would have the following form:

A

/ \

/ \

Q R

The difference between the RegRestoreKey function and the RegLoadKey function is that the RegLoadKey function uses the d supplied file is used as the backing store, while the RegRestoreKey function copies the information in the file into the registry.

See Also

RegLoadKey, RegSaveKey