Visual Basic Language Reference  

GetAllSettings Function

Returns a list of key settings and their respective values (originally created with SaveSetting) from an application's entry in the Windows registry.

Public Function GetAllSettings( _
   ByVal AppName As String, _ 
   ByVal Section As String _
) As String(,)

Parameters

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. GetAllSettings returns an object that contains a two-dimensional array of strings. The strings contain all the key settings in the specified section plus their corresponding values.

Exceptions/Errors

Exception type Error number Condition
ArgumentException 5 User is not logged in.

Remarks

GetAllSettings returns an uninitialized Object if either AppName or Section does not exist.

GetAllSettings requires that a user be logged on since it operates under the HKEY_LOCAL_USER registry key, which is not active until a user logs on interactively.

Registry settings that are to be accessed from a non-interactive process (such as mtx.exe) should be stored under either the HKEY_LOCAL_MACHINE\Software\ or the HKEY_USER\DEFAULT\Software registry keys.

Example

This example first uses the SaveSetting statement to make entries in the Windows registry for the application specified as AppName, then uses the GetAllSettings function to display the settings. Note that application names and Section names can't be retrieved with GetAllSettings. Finally, the DeleteSetting statement removes the application's entries.

' Object to hold 2-dimensional array returned by GetAllSettings.
' Integer to hold counter.
Dim MySettings(,) As String
Dim intSettings As Integer
' Place some settings in the registry.
SaveSetting("MyApp", "Startup", "Top", "75")
SaveSetting("MyApp", "Startup", "Left", "50")
' Retrieve the settings.
MySettings = GetAllSettings("MyApp", "Startup")
For intSettings = LBound(MySettings, 1) To UBound(MySettings, 1)
   Debug.WriteLine(MySettings(intSettings, 0))
   Debug.WriteLine(MySettings(intSettings, 1))
Next intSettings
DeleteSetting("MyApp")

See Also

DeleteSetting Function | GetSetting Function | SaveSetting Function | ArgumentException