Returns a key setting value or type from an entry in the Windows registry using VB compatible registry commands.
$ = vbGetSetting(appName$, [section$], key$ [, ,default$])
% = vbGetSettingType(appName$, [section$], [key$])
These functions are VB compatible and return registry entries. The registry stores data in a hierarchically structured tree. Each node in the tree is called a key. Each key can contain both subkeys and data entries called values.
Visual Basic applications are required to store their registry settings under the entry called HKEY_CURRENT_USER\Software\VB and VBA Program Settings\appName\ section.
The vbGetSetting, vbGetSettingType, vbSaveSetting, vbDeleteSetting functions take appName and section as parameters to access the required entry in the HKEY_CURRENT_USER\Software\VB and VBA Program Settings\ registry key.
The vbGetSetting function syntax has these arguments:
appName - Required. String expression containing the name of the application or project whose key setting is requested. May include section in GFA-BASIC 32.
section - Optional. String expression containing the name of the section where the key setting is found.
key - Required. String expression containing the name of the key setting to return.
,default - Optional. Expression containing the value to return if no value is set in the key setting. If omitted, default is assumed to be a zero-length string ("").
If any of the items named in the vbGetSetting arguments do not exist, vbGetSetting returns the value of default.
The vbGetSettingType can be used to obtain the data type of the value of key$. Normally, the counter part of vbGetSetting, the VB compatible command vbSaveSetting saves data always in the string (REG_SZ) format.
vbSaveSetting "MyApp", "Startup", "Top", 75
vbSaveSetting "MyApp", "Startup", "Left", 50
Debug vbGetSetting("MyApp", "Startup", "Left", , 25)
Debug vbGetSettingType("MyApp", "Startup", "Left")
vbDeleteSetting "MyApp", "Startup"
vbDeleteSetting "MyApp"
It is possible to use the vbGetSetting statement to retrieve values form 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, like this:
HKEY_CURRENT_USER
\Software
\VB and VBA Program Settings
\MyApp
\Engines
\Jet
SystemDB = c:\access\system.mda
You can obtain nested levels in the Registry by using this syntax:
f$ = vbGetSetting("MyApp", "Engines\Jet", "SystemDB")
vbDeleteSetting does not work in the same fashion as they do with non-nested keys.
vbSaveSetting, vbDeleteSetting, GetSetting, GetSettingType, SaveSetting, DeleteSetting, CreateRegKey, OpenRegKey, CloseRegKey, GetRegVal, GetRegValName, GetRegValType, GetRegValNameCount, GetRegSubKey, GetRegSubKeyCount
{Created by Sjouke Hamstra; Last updated: 25/10/2014 by James Gaite}