RegUnLoadKey function

Unloads the specified registry key and its subkeys from the registry.

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.

Syntax


LONG WINAPI RegUnLoadKey(
  _In_      HKEY hKey,
  _In_opt_  LPCTSTR lpSubKey
);

Parameters

hKey [in]

A handle to the registry key to be unloaded. This parameter can be a handle returned by a call to RegConnectRegistry function or one of the following predefined handles:

HKEY_LOCAL_MACHINE
HKEY_USERS
lpSubKey [in, optional]

The name of the subkey to be unloaded. The key referred to by the lpSubKey parameter must have been created by using the RegLoadKey function.

Key names are not case sensitive.

For more information, see Registry Element Size Limits.

Return value

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.

Remarks

This function removes a hive from the registry but does not modify the file containing the registry information. A hive is a discrete body of keys, subkeys, and values that is rooted at the top of the registry hierarchy.

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.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winreg.h (include Windows.h)

Library

Advapi32.lib

DLL

Advapi32.dll

Unicode and ANSI names

RegUnLoadKeyW (Unicode) and RegUnLoadKeyA (ANSI)

See also

RegConnectRegistry
RegDeleteKey
Registry Functions
Registry Overview
RegLoadKey
RegRestoreKey

 

 

Community Additions

ADD
Show:
© 2014 Microsoft