Opens the specified registry key
#include <WinAPIReg.au3>
_WinAPI_RegOpenKey ( $vKey [, $sSubKey = '' [, $iAccess = $KEY_ALL_ACCESS]] )
$vKey | Name of the key to be open (see remarks). or Handle to an open registry key. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function, or it can be one of the following predefined keys: $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS |
$sSubKey | [optional] The name of the registry subkey to be opened (see remarks). |
$iAccess | [optional] A mask that specifies the desired access rights to the key. The function fails if the security descriptor of the key does not permit the requested access for the calling process. This parameter can be one or more of the $KEY_* constants. Default is $KEY_ALL_ACCESS. This parameter can have also the following values for opening whatever AutoIt running mode: $KEY_WOW64_32KEY for an 32-bit Key $KEY_WOW64_64KEY for an 64-bit Key By Default the key correspond to the @AutoItX64 value unless overrided by $KEY_WOW64_32KEY. |
Success: | Handle to the opened key. |
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code. |
$vKey can be a string containing the requested subkey in this case $sSubKey must be empty
Unlike the _WinAPI_RegCreateKey() function,
the _WinAPI_RegOpenKey() function does not create the specified key if the key does not exist in the registry.
If the key is not one of the predefined registry keys ($HKEY_*) you must call the _WinAPI_RegCloseKey() function after finished using the handle.
Key names are not case sensitive.
The $sSubKey parameter can be an an empty string.
If $sSubKey is an empty string and $vKey is $HKEY_CLASSES_ROOT, the return is the same $vKey handle passed into the function.
Otherwise, the return is a new handle to the key specified by $vKey.
The $sSubKey parameter can be NULL only if $vKey is one of the predefined keys.
If $sSubKey is NULL and $vKey is $HKEY_CLASSES_ROOT, the return is a new handle to the key specified by $vKey.
Otherwise, the return is the same $vKey handle passed in to the function.
_WinAPI_RegCloseKey, _WinAPI_RegCreateKey
Search RegOpenKeyEx in MSDN Library.
#include <APIRegConstants.au3>
#include <Date.au3>
#include <Debug.au3>
#include <WinAPIError.au3>
#include <WinAPILocale.au3>
#include <WinAPIReg.au3>
_DebugSetup(Default, True)
Example()
Func Example()
Local $hKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, 'SOFTWARE\AutoIt v3\AutoIt', $KEY_QUERY_VALUE)
If @error Then
_DebugReport("! RegOpenKey @error =" & @error & @CRLF & @TAB &_WinAPI_GetErrorMessage(@extended) & @CRLF)
Exit
EndIf
Local $tFT = _WinAPI_RegQueryLastWriteTime($hKey)
$tFT = _Date_Time_FileTimeToLocalFileTime($tFT)
Local $tST = _Date_Time_FileTimeToSystemTime($tFT)
_WinAPI_RegCloseKey($hKey)
_DebugReport('! Last modified at: ' & _WinAPI_GetDateFormat(0, $tST) & ' ' & _WinAPI_GetTimeFormat(0, $tST) & @CRLF)
EndFunc ;==>Example
#include <APIRegConstants.au3> #include <Date.au3> #include <Debug.au3> #include <MsgBoxConstants.au3> #include <WinAPIError.au3> #include <WinAPILocale.au3> #include <WinAPIReg.au3> _DebugSetup(Default, True) Example() Func Example() Local $hKey = _WinAPI_RegOpenKey('HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt', '', $KEY_QUERY_VALUE) If @error Then _DebugReport("! RegOpenKey @error =" & @error & @TAB & _WinAPI_GetErrorMessage(@extended) & @CRLF) Exit EndIf Local $tFT = _WinAPI_RegQueryLastWriteTime($hKey) $tFT = _Date_Time_FileTimeToLocalFileTime($tFT) Local $tST = _Date_Time_FileTimeToSystemTime($tFT) _WinAPI_RegCloseKey($hKey) _DebugReport('!Last modified at: ' & _WinAPI_GetDateFormat(0, $tST) & ' ' & _WinAPI_GetTimeFormat(0, $tST) & @CRLF) EndFunc ;==>Example
#AutoIt3Wrapper_UseX64=Y #include <Date.au3> #include <Debug.au3> #include <WinAPIError.au3> #include <WinAPILocale.au3> #include <WinAPIReg.au3> _DebugSetup(Default, True) Example() Func Example() Local $hKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, 'SOFTWARE\AutoIt v3\AutoIt', $KEY_QUERY_VALUE) If @error Then _DebugReport("! RegOpenKey @error = " & @error & @CRLF & @TAB & _WinAPI_GetErrorMessage(@extended) & @CRLF) Exit EndIf Local $tFT = _WinAPI_RegQueryLastWriteTime($hKey) $tFT = _Date_Time_FileTimeToLocalFileTime($tFT) Local $tST = _Date_Time_FileTimeToSystemTime($tFT) _WinAPI_RegCloseKey($hKey) _DebugReport('- Last modified at: ' & _WinAPI_GetDateFormat(0, $tST) & ' ' & _WinAPI_GetTimeFormat(0, $tST) & @CRLF) EndFunc ;==>Example