Microsoft KB Archive/145694

= INFO: SaveSetting & GetSetting Allow Nested Settings =

Article ID: 145694

Article Last Modified on 5/7/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q145694



SUMMARY
It is possible to use the SaveSetting statement to create nested levels of keys and values in the Registry. This behavior is desirable in some cases.

For example, when receiving the location of a SYSTEM.MDA file, the Access engine expects the SystemDB value to exist in a subkey of Engines\Jet, such as this:

  HKEY_CURRENT_USER \Software \VB and VBA Program Settings \MyApp \Engines \Jet SystemDB = c:\access\system.mda

Simply using the syntax for GetSetting supplied in the documentation and online help does not allow for this functionality.



MORE INFORMATION
You can create nested levels in the Registry by using this syntax:

SaveSetting "TestApp", "Test2\Test3", "TestVal", "TestSetting"

This will create a section of the Registry that looks like:

  HKEY_CURRENT_USER \Software \VB and VBA Program Settings \TestApp \Test2 \Test3 TestVal = TestSetting

This will only work with the 32-bit version of Visual Basic. If the same line of code is executed with Visual Basic 4.0 16-bit, the result will be a file named TESTAPP.INI, with the following section:

  [Test2\Test3] TestVal=TestSetting

To retrieve values stored in the Registry like this, use the same syntax with the GetSetting function.

Some restrictions are inherited when creating nested keys with SaveSetting.

DeleteSetting and GetAllSettings do not work in the same fashion as they do with non-nested keys.

Additional query words: kbVBp400 kbVBp500 kbVBp600 kbVBp kbdsd kbDSupport kbRegistry kbVBA

Keywords: kbinfo KB145694

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.