Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

RegLoadKeyA function (winreg.h)

Feedback

In this article

Creates a subkey underHKEY_USERS orHKEY_LOCAL_MACHINE and loads the data from the specified registry hive into that subkey.

Applications that back up or restore system state including system files and registry hives should use theVolume Shadow Copy Service instead of the registry functions.

Syntax

LSTATUS RegLoadKeyA(  [in]           HKEY   hKey,  [in, optional] LPCSTR lpSubKey,  [in]           LPCSTR lpFile);

Parameters

[in] hKey

A handle to the key where the subkey will be created. This can be a handle returned by a call toRegConnectRegistry, or one of the following predefined handles:

HKEY_LOCAL_MACHINEHKEY_USERSThis function always loads information at the top of the registry hierarchy. TheHKEY_CLASSES_ROOT andHKEY_CURRENT_USER handle values cannot be specified for this parameter, because they represent subsets of theHKEY_LOCAL_MACHINE andHKEY_USERS handle values, respectively.

[in, optional] lpSubKey

The name of the key to be created underhKey. This subkey is where the registration information from the file will be loaded.

Key names are not case sensitive.

For more information, seeRegistry Element Size Limits.

[in] lpFile

The name of the file containing the registry data. This file must be a local file that was created with theRegSaveKey function. If this file does not exist, a file is created with the specified name.

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 theFormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.

Remarks

There are two registry hive file formats. Registry hives created on current operating systems typically cannot be loaded by earlier ones.

IfhKey is a handle returned byRegConnectRegistry, then the path specified inlpFile is 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, seeRunning with Special Privileges. To load a hive without requiring these special privileges, use theRegLoadAppKey function.

Note

The winreg.h header defines RegLoadKey as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, seeConventions for Function Prototypes.

Requirements

RequirementValue
Minimum supported clientWindows 2000 Professional [desktop apps only]
Minimum supported serverWindows 2000 Server [desktop apps only]
Target PlatformWindows
Headerwinreg.h (include Windows.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll

See also

RegConnectRegistry

RegDeleteKey

RegLoadAppKey

RegReplaceKey

RegRestoreKey

RegSaveKey

RegUnLoadKey

Registry Functions

Registry Hive


Feedback

Was this page helpful?

YesNoNo

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?

  • Last updated on

In this article

Was this page helpful?

YesNo
NoNeed help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?