Function Reference


Retrieves the type and data for a list of value names associated with an open registry key

#include <WinAPIReg.au3>
_WinAPI_RegQueryMultipleValues ( $hKey, ByRef $aValent, ByRef $pBuffer [, $iStart = 0 [, $iEnd = -1]] )


$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 :
$aValent The 2D array ([valuename1, *, *, *], ... [valuenameN, *, *, *]) that contains a value names to be retrieved.
On input, 1, 2, and 3 array elements are not used, but array dimensions should be [n][4], otherwise the function fails.
Also, this function fails if any of the specified values do not exist in the specified registry key.
$pBuffer A pointer to a memory buffer that contains a registry data. Typically, you should not use this buffer directly (see remarks).
$iStart [optional] The index of array to start querying at.
$iEnd [optional] The index of array to stop querying at.

Return Value

Success: The number of bytes copied to the buffer. The $aValent array will contain the following data:
[n][0] - The name of the value (remain unchanged).
[n][1] - The size of the data, in bytes.
[n][2] - The pointer to the data in buffer pointed to by the $pBuffer parameter.
[n][3] - The type of data ($REG_*).
Failure: Sets the @error flag to non-zero, @extended flag may contain the system error code.


To prevent excessive serialization, the aggregate data returned by the function cannot exceed one megabyte.

When a returned registry data are no longer needed, you must free the allocated memory pointed to by the
$pBuffer parameter by calling the _WinAPI_FreeMemory() function.


_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegQueryMultipleValues in MSDN Library.


#include <APIRegConstants.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIReg.au3>
#include <WinAPISys.au3>

Local $aValent[19][4]

; Note that if at least one of the following value names is not found in the specified registry key, the function fails!

; HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

$aValent[0][0] = 'AppData'
$aValent[1][0] = 'Cache'
$aValent[2][0] = 'Cookies'
$aValent[3][0] = 'Desktop'
$aValent[4][0] = 'Favorites'
$aValent[5][0] = 'History'
$aValent[6][0] = 'Local AppData'
$aValent[7][0] = 'My Music'
$aValent[8][0] = 'My Pictures'
$aValent[9][0] = 'My Video'
$aValent[10][0] = 'NetHood'
$aValent[11][0] = 'Personal'
$aValent[12][0] = 'PrintHood'
$aValent[13][0] = 'Programs'
$aValent[14][0] = 'Recent'
$aValent[15][0] = 'SendTo'
$aValent[16][0] = 'Start Menu'
$aValent[17][0] = 'Startup'
$aValent[18][0] = 'Templates'

_ArrayDisplay($aValent, '_WinAPI_RegQueryMultipleValues')

Local $hKey = _WinAPI_RegOpenKey($HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', $KEY_QUERY_VALUE)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))

Local $pBuffer
_WinAPI_RegQueryMultipleValues($hKey, $aValent, $pBuffer)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))


_ArrayDisplay($aValent, '_WinAPI_RegQueryMultipleValues')

For $i = 0 To UBound($aValent) - 1
    $aValent[$i][2] = DllStructGetData(DllStructCreate('wchar[' & $aValent[$i][1] & ']', $aValent[$i][2]), 1)


_ArrayDisplay($aValent, '_WinAPI_RegQueryMultipleValues')