DeleteSetting Procedure


DeleteSetting Procedure

Class

Microsoft.VisualBasic.Interaction

Syntax

     DeleteSetting(appname[, section[, key]]) 


appname (required; String)

The name of the application branch to be deleted or that contains the setting to be deleted.


section (optional; String)

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


key (optional; String)

The name of the value entry to delete.

Description

The DeleteSetting procedure deletes a complete application settings branch, one of its subkeys, or a single value entry within a subkey. All of these settings values are stored in the Windows registry.

Usage at a Glance

  • You cannot use DeleteSetting to delete entries from registry keys that are not subkeys of HKEY_CURRENT_USER\Software\VBand VBA ProgramSettings.

  • 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 deleted. For example, to delete the value entry named TestKey in the registry key HKEY_CURRENT_USER\Software\VB and VBA ProgramSettings\RegTester\BranchOne\BranchTwo, you would use:

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

  • If key is supplied, only the value entry named key and its associated value are deleted. If key is omitted, the subkey named section is deleted. If section is omitted, the entire application branch named appname is deleted.

  • DeleteSetting cannot be used to delete the default value (i.e., the unnamed value entry) belonging to any key. If you are using only the VB registry functions, though, this is not a serious limitation, since SaveSetting does not allow you to create a default value.

  • Care should be used with this function, since it will allow you to delete entries created by other Visual Basic applications.

  • If the key or branch to be deleted does not exist, an error occurs.

  • 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

GetAllSettings Function, GetSetting 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