RegCreateKeyEx

Returns a handle to a new or existing registration database key.

Syntax:

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

Parameters:

(i) handle handle to a registration database key.

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

(s) mode access mode (see below).

(i) options returned key's lifetime (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.

Returns:

(i) handle a handle to the new key.

 

The RegCreateKeyEx function will create and open a desired key into the Registration Database. If the key already exists, RegCreateKeyEx will open it. When using RegCreateKeyEx you must pass a pre-existing, open key to create a new key. A pre-defined key may be used.

This function is like RegCreateKey, but lets the user specify the desired access rights (RegCreateKey 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.

 

Options

"Options" may be one of the following pre-defined numeric values:

Value

Name

Meaning

0

REG_OPTION_NON_VOLATILE

The information is stored in a registry hive or file and is preserved when the system is restarted. WIL registry functions that cause keys to be saved will saves keys that are marked non-volatile.

1

REG_OPTION_VOLATILE

The information for the key  is stored in memory and is not preserved when the keys containing registry hive is unloaded. For the predefined key @REGMACHINE, this occurs only when the system initiates a full shutdown. For keys created in other predefined registry key locations, this occurs when the current user  signs off..WIL registry functions that cause keys to be saved do not save volatile keys. This flag is ignored for keys that already exist.

2

REG_OPTION_CREATE_LINK

Creates a key that serves as a symbolic link to another key in registration database. In order to complete the symbolic link the RegSetEx function must be called using that functions REG_LINK (6) option. Once the link is established all registry operations performed on the link key except calls to  the RegDeleteLink and the RegOpenKeyEx  function using  option 6 are performed on the real key linked to the symbolic link key instead of the symbolic link key. The handle returned for symbolic link key option should only be passed to  RegSetEx and RegCloseKey. All other registration database functions can error or behave unpredictably when passed the key created with this option. Also note that unlike for other keys this function will not open existing symbolic link keys. See RegDeleteLInk for a usage example.

 

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:

Example:
  ;;; Associate ".diz" fils with the text editor.
  Options = 1 ; Key exists until the user sign out.
  View = 0 ;  @REGCLASSES usually only has one view.
  Key = RegCreateKeyEx(@regclasses,'.diz','WRITE',Options ,View)
  RegSetValue(key,"","txtfile")
  RegCloseKey(key)
  Message("RegCreatekey","*.DIZ files associated with your text editor until you sign out")
See Also:

RegOpenKey, RegOpenKeyEx,  RegCreateKey, RegCloseKey, RegDeleteKey, RegDeleteLink, RegEntryType, RegSetValue, RegSetEx, RegQueryKeys, RegQueryValue, and the section on Registration Database Operations