Visual Basic Language Reference  

SaveSetting Function

Saves or creates an application entry in the Windows registry.

Public Sub SaveSetting( _
   ByVal AppName As String, _ 
   ByVal Section As String, _
   ByVal Key As String, _
   ByVal Setting As String _
)

Parameters

AppName
Required. String expression containing the name of the application or project to which the setting applies.
Section
Required. String expression containing the name of the section in which the key setting is being saved.
Key
Required. String expression containing the name of the key setting being saved.
Setting
Required. Expression containing the value to which Key is being set.

Exceptions/Errors

Exception type Error number Condition
ArgumentException 5 Key registry could not be created, or user is not logged in.

Remarks

If the key setting can't be saved for any reason, an error occurs.

SaveSetting 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

The following example first uses the SaveSetting statement to make entries in the Windows registry for the MyApp application, and then uses the DeleteSetting statement to remove them.

' Place some settings in the registry.
SaveSetting("MyApp", "Startup", "Top", "75")
SaveSetting("MyApp","Startup", "Left", "50")
' Remove Startup section and all its settings from registry.
DeleteSetting ("MyApp", "Startup")
' Remove MyApp from the registry.
DeleteSetting ("MyApp")

See Also

DeleteSetting Function | GetAllSettings Function | GetSetting Function