Funktionreferenz


_WinAPI_RegCloseKey


Closes a handle to the specified registry key

#include <WinAPIReg.au3>
_WinAPI_RegCloseKey ( $hKey [, $bFlush = False] )

Parameter

$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).

Rückgabewert

Success: 1.
Failure: 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Bemerkungen

None.

Verwandte Funktionen

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

Siehe auch

Suche nach RegCloseKey in der MSDN Bibliothek.

Beispiel

Beispiel 1

#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

Example First parameter being the full Key string

#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

Example 3 Running in X64 Mode (should be run under Full SciTE4AutoIt)

#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