Function Reference


Creates the specified registry key

#include <WinAPIReg.au3>
_WinAPI_RegCreateKey ( $hKey [, $sSubKey = '' [, $iAccess = $KEY_ALL_ACCESS [, $iOptions = 0 [, $tSecurity = 0]]]] )


$hKey Handle to an open registry key. If the key already exists, the function opens it. The calling process
must have $KEY_CREATE_SUB_KEY access to the key. This handle is returned by the _WinAPI_RegCreateKey()
or _WinAPI_RegOpenKey() function, or it can be one of the following predefined keys.
$sSubKey [optional] The name of a subkey that this function opens or creates. The subkey specified must be a subkey of
the key identified by the $hKey parameter; it can be up to 32 levels deep in the registry tree.
If an empty string (Default), the return is a new handle to the key specified by $hKey.
$iAccess [optional] The mask that specifies the access rights for the key.
This parameter can be one or more of the following values.
$iOptions [optional] This parameter can be one of the following values.
$tSecurity [optional] $tagSECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by
child processes. If this parameter is 0 (Default), the handle cannot be inherited.

Return Value

Success: Handle to the opened or created key, @extended flag will contain one of the following
disposition values:
0 (False) - The key existed and was simply opened without being changed.
1 (True) - The key did not exist and was created.
Failure: Sets the @error flag to non-zero, @extended flag may contain the system error code.


An application cannot create a key that is a direct child of HKEY_USERS or HKEY_LOCAL_MACHINE. An application
can create subkeys in lower levels of the HKEY_USERS or HKEY_LOCAL_MACHINE trees.

If the key is not one of the predefined registry keys ($HKEY_*) you must call the _WinAPI_RegCloseKey()
function after finished using the handle.



See Also

Search RegCreateKeyEx in MSDN Library.