RegOpenKey

RegOpenKey opens the specified registry key.

Syntax

Copy
LONG RTAPI RegOpenKey(
    [in]            HKEY         hKey,
    [in, optional]  LPCTSTR      lpSubKey,
    [out]           PHKEY        phkResult 
  );

Parameters

[in] hKey

Handle which can only be one of the following predefined keys.

[in, optional] lpSubKey

The name of a key that this function opens or creates. This key must be a subkey of the key identified by the hKey parameter. Key names are not case sensitive. If this parameter is NULL or a pointer to an empty string, the function returns the handle to the predefined hKey parameter.

[out] phkResult

A pointer to a variable that receives a handle to the opened key. If the key is not one of the predefined registry keys, call the RegCloseKey function after you have finished using the handle.

Return Value

If the function succeeds, it returns ERROR_SUCCESS. If the function fails, it returns a non-zero error code.

Remarks

The RegOpenKey function uses the default security access mask to open a key. If opening the key requires a different access right, the function fails, returning ERROR_ACCESS_DENIED. An application should use the RegOpenKeyEx function to specify an access mask in this situation. The application program should call RegCloseKey when handle is not in use or upon application exit.

RegOpenKey does not create the specified key if the key does not exist in the database.

Requirements

Minimum supported version Header Library

wRTOS 1.0 SDK

windows.h

wRTOS_rtss.lib

See Also: