Function Reference


Retrieves the type and data for the specified value name associated with an open registry key

#include <WinAPIReg.au3>
_WinAPI_RegQueryValue ( $hKey, $sValueName, ByRef $tValueData )


$hKey Handle to an open registry key. The key must have been opened with the KEY_QUERY_VALUE access right.
This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. It can also
be one of the following predefined keys.
$sValueName The name of the registry value. If $sValueName is empty string, the function retrieves the type and
data for the key's unnamed or default value, if any.
$tValueData The structure (buffer) that receives the value data. This structure must be created before function call.

Return Value

Success: The size of the data copied to $tValueData, in bytes, @extended flag will contain the code that
indicates the data type ($REG_*).
Failure: 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.


If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, returned size includes any terminating null
character or characters unless the data was stored without them.

If the buffer specified by $tValueData parameter is not large enough to hold the data, the function returns
ERROR_MORE_DATA (234) and returns the required buffer size. In this case, the contents of the buffer are


_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegQueryValueEx in MSDN Library.


#include <APIRegConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIError.au3>
#include <WinAPIReg.au3>

; X64 running support
Local $sWow64 = ""
If @AutoItX64 Then $sWow64 = "\Wow6432Node"

Local $hKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, 'SOFTWARE' & $sWow64 & '\AutoIt v3\AutoIt', $KEY_QUERY_VALUE)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))

Local $tData = DllStructCreate('wchar[260]')
_WinAPI_RegQueryValue($hKey, 'InstallDir', $tData)

ConsoleWrite(DllStructGetData($tData, 1) & @CRLF)