RegCreateKey

RegCreateKey creates the specified registry key. If the key already exists in the registry, the function opens it. See the RegCreateKeyEx function for more expanded options.

Syntax

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

Parameters

[in] hKey

A handle to an open registry key. This handle is returned by the RegCreateKey, RegCreateKeyEx, RegOpenKey or RegOpenKeyEx  function, or it can 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 or created key.

Return Value

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

Remarks

This function cannot create a key that is a direct child of HKEY_USERS or HKEY_LOCAL_MACHINE. An application can create subkeys in lower levels of HKEY_USERS or HKEY_LOCAL_MACHINE trees.

An application should call RegCloseKey when finished using the handle or upon application exit.

An application can use the RegCreateKey function to create one level deep at once.

Requirements

Minimum supported version Header Library

wRTOS 1.0 SDK

windows.h

wRTOS_rtss.lib

See Also: