The Function will enumerate through the Registry Key (HKEY_CURRENT_USERVolatile Environment) adding the values to an Array. Because the final size of the Array is unknown, I've started to use ReDim in an efficent way! Check out _ReDim() for more details.
Note: This will work on XP and above, but it should be noted that "LOCALAPPDATA" can't be found on XP!
Function: Save as _GetSystemPaths.au3
; #FUNCTION# ==================================================================================================================== ; Name ..........: _GetSystemPaths ; Description ...: Retrieve details about the system paths from HKEY_CURRENT_USER\Volatile Environment\. ; Syntax ........: _GetSystemPaths() ; Parameters ....: None ; Return values .: Success - Returns a 2 dimensional array where element[n][0] is the registry item and element[n][1] is the value. ; The number of elements returned will be in $aArray[0][0]. ; Failure - None ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GetSystemPaths() Local $aReturn[1][3] = [[0, 3, 0]], _ $iCount = 1, _ $sRegistryKey = 'HKEY_CURRENT_USER\Volatile Environment\', $sRegistryValue = '' While 1 $sRegistryValue = RegEnumVal($sRegistryKey, $iCount) If @error Then ExitLoop EndIf If ($aReturn[0][0] + 1) >= $aReturn[0][2] Then $aReturn[0][2] = Ceiling(($aReturn[0][0] + 1) * 1.3) ReDim $aReturn[$aReturn[0][2]][$aReturn[0][1]] EndIf $aReturn[0][0] += 1 $aReturn[$aReturn[0][0]][0] = $sRegistryValue $aReturn[$aReturn[0][0]][1] = RegRead($sRegistryKey, $sRegistryValue) $iCount += 1 WEnd ReDim $aReturn[$aReturn[0][0] + 1][$aReturn[0][1] - 1] $aReturn[0][1] = '' Return $aReturn EndFunc ;==>_GetSystemPaths
Example use of Function:
#include <Array.au3> #include '_GetSystemPaths.au3' Local $aArray = _GetSystemPaths() _ArrayDisplay($aArray)
Edited by guinness, 09 April 2013 - 04:09 PM.






