RegOpenKey

  LONG RegOpenKey(hkey, lpszSubKey, phkResult)    
  HKEY hkey; /* handle of an open key */
  LPTSTR lpszSubKey; /* address of name of subkey to open */
  PHKEY phkResult; /* address of handle of open key */

The RegOpenKey function opens the specified key.

Parameters

hkey

Identifies a currently open key or any of the following predefined reserved handle values:

HKEY_CLASSES_ROOT HKEY_CURRENT_USER HKEY_LOCAL_MACHINE HKEY_USERS

The key opened by the RegOpenKey function is a subkey of the key identified by hkey.

lpszSubKey

Points to a null-terminated string specifying the name of the subkey to open. lpszSubKey is always relative to the key specified by hkey. This parameter must not be NULL.

phkResult

Points to a variable that receives the handle of the opened key.

Return Value

The return value is ERROR_SUCCESS if the function is successful. Otherwise, it is an error value.

Comments

Unlike the RegCreateKey function, the RegOpenKey function does not create the specified key if the key does not exist in the database.

The RegOpenKey function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).

See Also

RegCreateKey, RegCreateKeyEx, RegOpenKeyEx