Export (0) Print
Expand All

Interaction::SaveSetting Method

Saves or creates an application entry in the Windows registry. The My feature gives you greater productivity and performance in registry operations than SaveSetting. For more information, see Registry.

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public:
static void SaveSetting(
	String^ AppName, 
	String^ Section, 
	String^ Key, 
	String^ Setting
)

Parameters

AppName
Type: System::String

Required. String expression containing the name of the application or project to which the setting applies.

Section
Type: System::String

Required. String expression containing the name of the section in which the key setting is being saved.

Key
Type: System::String

Required. String expression containing the name of the key setting being saved.

Setting
Type: System::String

Required. Expression containing the value to which Key is being set.

ExceptionCondition
ArgumentException

Key registry could not be created, or user is not logged in.

The SaveSetting function adds the key to HKEY_CURRENT_USER\Software\VB and VBA Program Settings.

If the key setting cannot 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.

SaveSetting requires Write and Create RegistryPermission .

The following example first uses the SaveSetting function to make entries in the Windows registry for the MyApp application, and then uses the DeleteSetting function 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")

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft