GetSetting Function


GetSetting Function

Class

Microsoft.VisualBasic.Interaction

Syntax

     GetSetting(appname, section, key[, default]) 


appname (required; String)

The name of the application branch to be retrieved.


section (required; String)

The name of the application's subkey to be retrieved. This can be a single key or a relative registry path, with path components separated by backslashes.


key (required; String)

The name of the value entry to retrieve.


default (optional; String)

The value to return if no setting can be found. If omitted, the default value is an empty string ("").

Description

The GetSetting function returns a single value from a specified section of your application's entry in the HKEY_CURRENT_USER\Software\VB and VBA ProgramSettings\ branch of the registry. If a matching entry is not found, or if any portion of the path to the entry is not found, default is returned instead.

Usage at a Glance

  • section is a relative path (similar to that used to describe the directories on a hard drive) used to navigate from the application key to the subkey to be accessed. For example, to access the value entry named TestKey in the registry key HKEY_CURRENT_USER\Software\VB and VBA ProgramSettings\RegTester\BranchOne\BranchTwo, you would use:

         GetSetting("RegTester", "BranchOne\BranchTwo", "TestKey") 

  • Although the registry supports multiple data types, the GetSetting function only supports string values.

  • You cannot use GetSetting to access entries from registry keys that are not subkeys of HKEY_CURRENT_USER\Software\VB and VBA ProgramSettings.

  • GetSetting cannot be used to access the default value (i.e., the unnamed value entry) belonging to any key. If you're using only the VB registry functions, though, this isn't a serious limitation, since SaveSetting does not allow you to create a default value.

  • Data saved with SaveSetting is placed in the registry on a per-user basis.

  • The .NET Framework includes registry-related features that provide more flexibility than the VB "Settings" functions. These features are found in the Registry and RegistryKey classes of the Microsoft.Win32 namespace.

Version Differences

Visual Basic 2005 includes several new features that let you manage the settings used by an application. Although they are not compatible with the older VB "Settings" functions, they provide a richer set of features. These features are located in the My.Settings object. The My.Computer.Registry object also provides access to convenient registry-related features.

See Also

DeleteSetting Procedure, GetAllSettings Function, SaveSetting Procedure




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net