RegLoadKey

  LONG RegLoadKey(hkey, lpszSubKey, lpszFile);    
  HKEY hkey;    
  LPTSTR lpszSubKey;    
  LPTSTR lpszFile;    

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

Parameters

hkey

Specifies the predefined handle HKEY_LOCAL_MACHINE or HKEY_USERS.

lpszSubKey

Supplies a path name to a new (non-existent) key where the supplied file will be loaded.

lpszFile

Points to a null-terminated string that specifies the the name of a file whose contents were created with the RegSaveKey function. The file name may not have an extension.

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 lpszSubKey specifies key A, the result of the RegLoadKey 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

RegRestoreKey, RegSaveKey