GetAllSettings
Returns every key and its value in a section of an application’s entry in the Windows registry.
Syntax: GetAllSettings( appname , section )
- appname
- required String expression containing the name of the application or project whose key settings are requested.
- section
- required String expression containing the name of the section whose key settings are requested.
Returns a Variant whose contents are a two-dimensional array of strings: each row holds one key and its value, in columns 0 and 1 respectively. GetAllSettings returns an uninitialized Variant if either appname or section does not exist.
The root of these registry settings is: Computer\HKEY_CURRENT_USER\Software\VB and VBA Program Settings.
Common Errors
| Error | When |
|---|---|
-2147467259 (&H80004005), Unspecified error | appname or section is a zero-length string |
94 (&H5E), Invalid use of Null | appname or section is Null |
Note BETA 1034
When appname or section is a zero-length string, VB6 and 64-bit VBA raise error 5 (&H5), Invalid procedure call or argument, instead.
Example
This example first uses SaveSetting to make entries in the Windows registry for the application, then uses GetAllSettings to display every key/value in a section, and finally uses DeleteSetting to remove the application’s entries. Note that the appname and section names themselves are not retrieved.
' Place some settings in the registry.
SaveSetting AppName := "MyApp", Section := "Startup", _
Key := "Top", Setting := "75"
SaveSetting "MyApp", "Startup", "Left", "50"
' Retrieve them.
Dim MySettings As Variant, IntSettings As Long
MySettings = GetAllSettings(AppName := "MyApp", Section := "Startup")
For IntSettings = LBound(MySettings, 1) To UBound(MySettings, 1)
Debug.Print MySettings(IntSettings, 0), MySettings(IntSettings, 1)
Next IntSettings
DeleteSetting "MyApp", "Startup"
See Also
- DeleteSetting statement
- GetSetting function
- SaveSetting statement