OROpenHive function

Loads the specified registry hive file into memory and validates the hive.

Syntax

DWORD OROpenHive(
  _In_  PCWSTR  lpHivePath,
  _Out_ PORHKEY phkResult
);

Parameters

lpHivePath [in]

A pointer to a Unicode string that specifies the name of the registry hive file to be loaded into memory. This can be a hive file that was saved with the ORSaveHive function or created with the RegSaveKey or RegSaveKeyEx function. The file must be less than 4 GB in size, and the caller must have FILE_READ_DATA access to the file. For more information, see File Security and Access Rights.

phkResult [out]

A pointer to a variable that receives a handle to the root key of the loaded offline registry hive. If the registry hive file cannot be opened or validation fails, the function sets this parameter to NULL.

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. Possible error codes include the following:

  • If the file is empty or larger than 4 GB in size, the function returns ERROR_BADDB.
  • If the caller does not have the necessary access rights to open the file, the function returns ERROR_ACCESS_DENIED.
  • If the registry hive fails validation, the function returns ERROR_NOT_REGISTRY_FILE.

Remarks

The OROpenHive function is the only offline registry function that validates a registry hive. If the validation fails, no attempt is made to repair the hive.

Requirements

Requirement Value
Redistributable
Windows Offline Registry library version 1.0 or later
Header
Offreg.h
DLL
Offreg.dll

See also

ORCloseHive

ORCreateHive

ORSaveHive

RegSaveKey

RegSaveKeyEx