Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function opens the specified key.

A remote application interface (RAPI) version of this function exists called CeRegOpenKeyEx (RAPI).

Syntax

LONG RegOpenKeyEx( 
  HKEY 
hKey, 
  LPCWSTR 
lpSubKey, 
  DWORD 
ulOptions, 
  REGSAM 
samDesired, 
  PHKEY 
phkResult 
); 

Parameters

hKey

[in] Handle to a currently open key or any of the following predefined reserved handle values:

  • HKEY_LOCAL_MACHINE

  • HKEY_CLASSES_ROOT

  • HKEY_CURRENT_USER

  • HKEY_USERS

Windows Embedded CE does not support the HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATApredefined reserved handle values.

lpSubKey

[in] Pointer to a null-terminated string containing the name of the subkey to open. If this parameter is set to NULL or a pointer to an empty string, the function opens a new handle to the key identified by hKey. In this case, the function does not close the handles previously opened.

ulOptions

[in] Reserved. Set to zero.

samDesired

[in] Not supported. Set to zero.

phkResult

[out] Pointer to a variable that receives a handle to the opened key. When you no longer need the returned handle, call the RegCloseKeyfunction to close it.

Return Value

ERROR_SUCCESS indicates success. A nonzero error code defined in Winerror.h indicates failure. To get a generic description of the error, call the FormatMessagefunction with the FORMAT_MESSAGE_FROM_SYSTEM flag set. The message resource is optional, so FormatMessagemight fail.

Remarks

Unlike the RegCreateKeyExfunction, this function does not create the specified key if the key does not exist in the registry.

Requirements

Header winreg.h
Library coredll.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also