Closes a handle to the specified registry key
#include <WinAPIReg.au3>
_WinAPI_RegCloseKey ( $hKey [, $bFlush = False] )
$hKey | Handle to the open key to be closed. The handle must have been opened by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. |
$bFlush | [optional] Specifies whether writes all the attributes of the specified registry key into the registry, valid values: True - Write changes to disk before close the handle. False - Don't write (Default). |
Success: | 1. |
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code. |
_WinAPI_RegCreateKey, _WinAPI_RegOpenKey
Search RegCloseKey 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