The SetRegistryValue method saves a value in the Windows Registry. Since Stonefield Query stores its user settings in the Registry, and any additional options you define in an Options.Settings script are also stored there, this method is useful if you need to update the value of a setting programmatically.

Syntax

SetRegistryValue(ValueName as String, Value as String, 
    Node as String) as Boolean

Parameters
ValueName
The name of the value in the Registry.

Value
The value to store.

Node
The name of the node in the Registry to store the value in. If this parameter isn't passed, the value is stored in HKEY_CURRENT_USER\Software\CompanyName\ApplicationName\Options (where CompanyName and ApplicationName are the values of the Company Name and Application Name configuration settings). If a value is passed and it doesn't contain a backslash (\), that node is used instead of Options. For example, specifying "Data" means that HKEY_CURRENT_USER\Software\CompanyName\ApplicationName\Data is used. If it does contain a backslash, then it must be a complete path to any place in the Registry, such as HKEY_LOCAL_MACHINE\Software\Whatever\SomeNode.

Return Value
True if the value was saved.

Example
Here's an example that adds a value to the Registry if a certain file exists.

Visual FoxPro

lparameters toApplication as SQApplication
if file('Settings.cfg')
  toApplication.SetRegistryValue('Use Config Settings', 'Y')
endif

VBScript

function Main(Application)
dim fso
set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists("Settings.cfg")
  Application.SetRegistryValue("Use Config Settings", "Y")
end if
end function

JavaScript

function Main(Application, Directory) {
var fso ;
fso = new ActiveXObject('Scripting.FileSystemObject') ;
if (fso.FileExists('Settings.cfg'))
  Application.SetRegistryValue('Use Config Settings', 'Y') ;
}

C#

public static bool CheckConfigSettings(SFQApplication sfqApplication, string directory)
{	
  if(File.Exists("Settings.cfg"))
  {
    sfqApplication.SetRegistryValue("Use Config Settings", "Y");
  }
  return true;
}

VB.NET

public shared function CheckConfigSettings(sfqApplication as SFQApplication,
    directory as string) as Boolean
  if File.Exists("Settings.cfg")
    sfqApplication.SetRegistryValue("Use Config Settings", "Y")
  End if
  return True
End Function

See also

Application Object | GetRegistryValue | SetINIValue

© Stonefield Software Inc., 2023 • Updated: 06/06/16
Comment or report problem with topic