Platform SDK: Registry |
The RegOpenKey function opens the specified registry key.
Note This function is provided only for compatibility with 16-bit versions of Windows. Win32-based applications should use the RegOpenKeyEx function.
LONG RegOpenKey( HKEY hKey, // handle to open key LPCTSTR lpSubKey, // name of subkey to open PHKEY phkResult // handle to open key );
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
Windows NT/2000: HKEY_PERFORMANCE_DATA
Windows 95/98: HKEY_DYN_DATA
The key opened by the RegOpenKey function is a subkey of the key identified by hKey.
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.
The RegOpenKey function uses the default security access mask to open a key. If opening the key requires a different mask, the function fails, returning ERROR_ACCESS_DENIED. An application should use the RegOpenKeyEx function to specify an access mask in this situation.
Unlike the RegCreateKey function, RegOpenKey does not create the specified key if the key does not exist in the database.
Windows 95/98: No registry subkey or value name may exceed 255 characters.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winreg.h; include Windows.h.
Library: Use Advapi32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
Registry Overview, Registry Functions, RegCloseKey, RegCreateKey, RegCreateKeyEx, RegDeleteKey, RegOpenKeyEx