Deletes a section or key setting from an application's entry in the Windows registry.
Public Sub DeleteSetting( _ ByVal AppName As String, _ Optional ByVal Section As String = Nothing, _ Optional ByVal Key As String = Nothing _ )
Exception type | Error number | Condition |
---|---|---|
5 | Section, AppName, or Key setting does not exist. | |
5 | User is not logged in. |
If all arguments are provided, the specified setting is deleted. A run-time error occurs if you attempt to use DeleteSetting on a nonexistent section or key setting.
DeleteSetting 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.
The following example first uses the SaveSetting procedure to make entries in the Windows registry for the MyApp
application, and then uses the DeleteSetting statement to remove them. Because no Key argument is specified, the whole Startup
section is deleted, including the section name and all of its keys.
' Place some settings in the registry. SaveSetting("MyApp", "Startup", "Top", "75") SaveSetting("MyApp","Startup", "Left", "50") ' Remove section and all its settings from registry.DeleteSetting (
"MyApp",
"Startup") ' Remove MyApp from the registry.DeleteSetting (
"MyApp")
GetAllSettings Function | GetSetting Function | SaveSetting Function |