RegOpenKeyEx

Opens a registry key with specified access rights.

Syntax:

RegOpenKeyEx( handle, subkey-string, mode[, view-flag[, options]] )

Parameters:

(i) handle handle to a registration database key

(s) subkey-string a path from the key provided to the desired key

(s/i) mode access mode (see below)

(i) view-flag [optional] controls which registry view the function uses when accessing the Windows registry.
0 - view indicated by the last call to the RegOpenFlags.
32 - use the 32-bit registry view.
64 - use the 64-bit registry view.

(s/i) option [optional] set to 8 (REG_OPTION_OPEN_LINK) to open a symbolic link key otherwise set to 0 or an empty string (""). See below.

Returns:

(i) handle  a handle to the newly-opened key.

 

This function is like RegOpenKey, but lets the user specify the desired access rights (RegOpenKey opens a key with default access, so may fail if the user only has read permission for the key).

"Mode" may be one of the following pre-defined string values:

Value

Name

Meaning (see below for bit descriptions)

"READ"

KEY_READ

KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | STANDARD_RIGHTS_READ

 

"WRITE"

KEY_WRITE

KEY_SET_VALUE | KEY_CREATE_SUB_KEY | STANDARD_RIGHTS_WRITE 

 

"FULL"

KEY_ALL_ACCESS

(KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK | STANDARD_RIGHTS_ALL) & ~SYNCHRONIZE

 

 

Or, "mode" may be a bitmask comprised of one or more of the following integer values, combined using the bitwise OR ('|') operator:

 

Value

Name

Meaning

1

KEY_QUERY_VALUE

Permission to query subkey data.

2

KEY_SET_VALUE

Permission to set subkey data.

4

KEY_CREATE_SUB_KEY

Permission to create subkeys.

8

KEY_ENUMERATE_SUB_KEYS

Permission to enumerate subkeys.

16

KEY_NOTIFY

Permission for change notification.

32

KEY_CREATE_LINK

Permission to create a symbolic link.

 

View-flag

This optional parameter controls which registry view the function uses when accessing the Windows registry. The optional parameter's values can be 32 to use the 32-bit view, 64 to use the 64-bit view, or 0 to use the view indicated by the last call to the RegOpenFlags. The parameter value of 0 can also causes a function to use the WinBatch default 64-bit view, if no call to RegOpenFlags has been made and setting the parameter to 0 is equivalent to omitting the parameter entirely.

Notes:

Option

When the option parameter is set to 8 the function opens a symbolic link key. In order for the function to open a symbolic link key the first parameter must be one of the pre-defined registration database handles @REGMACHINE, @RECLASSES, @REGUSERS, or @REGCURRENT.  If the subkey is not a symbolic link or the first parameter is not one of the mentioned pre-defined keys, the function will error. The handle returned for symbolic link key option can only be used with the RegSetEx function to associate a real key to associate a real key with the symbolic link or with the RegCloseKey function to close the key..

Note if you attempt to open a symbolic link key without specifying option 8, the function will return an open handle to the real key pointed to by the symbolic link key.

Value

Name

Meaning

8

REG_OPTION_OPEN_LINK

Open a symbolic link key instead of the key associated with the symbolic link key.

 

See Also:

RegOpenFlags, RegCloseKey, RegOpenKey RegSetEx, and the section on Registration Database Operations