The GetRegistryValue method returns a value from the Windows Registry. Since Stonefield Query stores its user settings in the Registry, and any additional options you define in an Options.Settings or Setup.Settings script may be stored there, this method is useful if you need to determine the value of a setting.


GetRegistryValue(ValueName as String, DefaultValue as String, 
    Node as String) as String

The name of the value in the Registry.

The value to return if the name isn't found in the Registry. Optional: if this parameter isn't specified, a blank string is returned.

The name of the node in the Registry that the value can be found in. If this parameter isn't passed, the value is looked for 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
The value in the Registry if it was found or DefaultValue if not.

Here's an example that uses some custom options settings defined in an Options.Settings script. If the "Report on AR data" option is No, all AR tables are marked as not reportable. If the option is Yes, then the "Location of AR data" setting is used as the location for the AR tables. This code goes into the DataEngine.GetCustomMetaData script.

Visual FoxPro

lparameters toApplication as SQApplication
local lcValue, lcLocation, lnI, loTable as Table
lcValue = toApplication.GetRegistryValue('AR Data')
lcLocation = toApplication.GetRegistryValue('AR Location')
for lnI = 1 to toApplication.DataEngine.Tables.Count
  loTable = toApplication.DataEngine.Tables.Item(lnI)
  do case
    case left(loTable.Alias, 2) <> 'AR'
    case lcValue = 'Y'
      loTable.Location = lcLocation
      loTable.Reportable = .F.


function Main(Application)
dim Table
Value = Application.GetRegistryValue("AR Data")
Location = Application.GetRegistryValue("AR Location")
for I = 1 to Application.DataEngine.Tables.Count
  set Table = Application.DataEngine.Tables.Item(I)
  if left(Table.Alias, 2) = "AR" then
    if Value = "Y" then
      Table.Location = Location
      Table.Reportable = False
    end if
  end if
end function


function Main(Application) {
var Value, Location, I, Table ;
Value = Application.GetRegistryValue('AR Data') ;
Location = Application.GetRegistryValue('AR Location') ;
for (I = 1; I <= Application.DataEngine.Tables.Count; I++) {
  Table = Application.DataEngine.Tables.Item(I) ;
  if (left(Table.Alias, 2) = 'AR') {
    if (Value = 'Y') {
      Table.Location = Location ;
    else {
      Table.Reportable = false ;


public static bool DataEngine_GetCustomMetaData(SFQApplication sfqApplication)
  string value = sfqApplication.GetRegistryValue("AR Data");
  string location = sfqApplication.GetRegistryValue("AR Location");
  foreach(Table table in sfqApplication.DataEngine.Tables)
    if (table.Alias.Substring(0, 2) == "AR") 
      if (value == "Y") 
        table.Location = location;
        table.Reportable = false;
 return true;


public shared function DataEngine_GetCustomMetaData(sfqApplication as SFQApplication) as Boolean
  Dim location As String = sfqApplication.GetRegistryValue("AR Location")
  Dim value As String = sfqApplication.GetRegistryValue("AR Data")

  For Each table As Table In sfqApplication.DataEngine.Tables
    If table.Alias.Substring(0, 2) = "AR" Then
      If value = "Y" Then
        table.Location = location
        table.Reportable = False
      End If
    End If

  Return True
End Function

See also

Application Object | SetINIValue | SetRegistryValue

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