Registry Procedures

👉 Most of the procedures listed below will require that any program using them must be run with Administrator rights.


REGSTRING$ function

Purpose:

REGSTRING$ returns the string data for a specified value name associated with a registry key.

Syntax:

RetStr = REGSTRING$(HndlKey AS HKEY, _
                   SubKey AS STRING, _
                ValueName AS STRING)

Return Value:

  • Data type: STRING
    RetStr Data string retrieved from the specified registry key.

Parameters:

  • Data type: HKEY
    HndlKey A handle to an open registry key, which can be one of the always open predefined handles.
    • HKEY_CLASSES_ROOT
    • HKEY_CURRENT_USER
    • HKEY_LOCAL_MACHINE
    • HKEY_USERS
    • HKEY_CURRENT_CONFIG
    • HKEY_DYN_DATA
  • Data type: STRING
    SubKey The name of the subkey to open.
  • Data type: STRING
    ValueName The name of the registry value from which string data is to be retrieved.

CREATEREGSTRING statement

Purpose:

CREATEREGSTRING is used to create and update Registry Keys.

Syntax:

CREATEREGSTRING(HndlKey AS HKEY, _
               SubKey AS STRING, _
            ValueName AS STRING, _
              DataStr AS STRING)

Parameters:

  • Data type: HKEY
    HndlKey A handle to an open registry key, which can be one of the always open predefined handles.
    • HKEY_CLASSES_ROOT
    • HKEY_CURRENT_USER
    • HKEY_LOCAL_MACHINE
    • HKEY_USERS
    • HKEY_CURRENT_CONFIG
    • HKEY_DYN_DATA
  • Data type: STRING
    SubKey The name of the subkey that CREATEREGSTRING opens or creates.
  • Data type: STRING
    ValueName The name of the registry value to be set.
  • Data type: STRING
    DataStr The variable or literal string data to be stored.

DELETEREGKEY statement

Purpose:

DELETEREGKEY is used to delete a Registry Key including all of its values.

Syntax:

DELETEREGKEY(HndlKey AS HKEY, SubKey AS STRING)

Parameters:

  • Data type: HKEY
    HndlKey A handle to an open registry key, which can be one of the always open predefined handles.
    • HKEY_CLASSES_ROOT
    • HKEY_CURRENT_USER
    • HKEY_LOCAL_MACHINE
    • HKEY_USERS
    • HKEY_CURRENT_CONFIG
    • HKEY_DYN_DATA
  • Data type: STRING
    SubKey The name of the subkey to be deleted.

Example:

MACRO HKLM = HKEY_LOCAL_MACHINE

DELETEREGKEY(HKLM, "Software\Bcx-32\Bcx\Settings")

CREATEREGSTRING(HKLM, "Software\Bcx-32\Bcx\Settings", "Path", "C:\BCX")
PRINT REGSTRING$(HKLM, "Software\Bcx-32\Bcx\Settings", "Path")

CREATEREGSTRING(HKLM, "Software\Bcx-32\Bcx\Settings", "Path", "C:\Dev\BCX\bin")
PRINT REGSTRING$(HKLM, "Software\Bcx-32\Bcx\Settings", "Path")

CREATEREGSTRING(HKLM, "Software\Bcx-32\Bcx\Settings", "Vers", "7.4.7")
PRINT REGSTRING$(HKLM, "Software\Bcx-32\Bcx\Settings", "Vers")

REGINT function

Purpose:

REGINT returns the integer value for a specified ValueName associated with a registry key.

Syntax:

RetVal = REGINT(HndlKey AS HKEY, _
               SubKey AS STRING, _ 
            ValueName AS STRING)

Return Value:

  • Data type: INTEGER
    RetVal The value retrieved from the specified registry key.

Parameters:

  • Data type: HKEY
    HndlKey A handle to an open registry key, which can be one of the always open predefined handles.
    • HKEY_CLASSES_ROOT
    • HKEY_CURRENT_USER
    • HKEY_LOCAL_MACHINE
    • HKEY_USERS
    • HKEY_CURRENT_CONFIG
    • HKEY_DYN_DATA
  • Data type: STRING
    SubKey The name of the subkey to open.
  • Data type: STRING
    ValueName The name of the registry value from which integer data is to be retrieved.

CREATEREGINT statement

Purpose:

CREATEREGINT is used to create and update Registry Keys.

Syntax:

  CREATEREGINT(HndlKey AS HKEY, _
              SubKey AS STRING, _
           ValueName AS STRING, _
            DataInt AS INTEGER)

Parameters:

  • Data type: HKEY
    HndlKey A handle to an open registry key, which can be one of the always open predefined handles.
    • HKEY_CLASSES_ROOT
    • HKEY_CURRENT_USER
    • HKEY_LOCAL_MACHINE
    • HKEY_USERS
    • HKEY_CURRENT_CONFIG
    • HKEY_DYN_DATA
  • Data type: STRING
    SubKey The name of the subkey that CREATEREGINT opens or creates.
  • Data type: STRING
    ValueName The name for the storage location of DataInt.
  • Data type: INTEGER
    DataInt The variable or literal integer data to be stored.

Example:

MACRO HKLM = HKEY_LOCAL_MACHINE

CREATEREGINT(HKLM, "Software\Chevy", "Engine", 350)

PRINT REGINT(HKLM, "Software\Chevy", "Engine")

REGEXIST function

Purpose:

REGEXIST determines whether a registry key or value name exists.

Syntax:

RetVal = REGEXIST(HndlKey AS HKEY, _
                 SubKey AS STRING, _
              ValueName AS STRING)

Return Value:

  • Data type: INTEGER
    RetVal The value is
    • zero if the SubKey and ValueName exist.
    • greater than zero if the SubKey doesn't exist.
    • less than zero if the ValueName doesn't exist.

    Parameters:

    • Data type: HKEY
      HndlKey A handle to an open registry key, which can be one of the always open predefined handles.
      • HKEY_CLASSES_ROOT
      • HKEY_CURRENT_USER
      • HKEY_LOCAL_MACHINE
      • HKEY_USERS
      • HKEY_CURRENT_CONFIG
      • HKEY_DYN_DATA
    • Data type: STRING
      SubKey The name of the subkey.
    • Data type: STRING
      ValueName The value name.

Example:

MACRO HKLM = HKEY_LOCAL_MACHINE

PRINT "A zero value means that the key and value name exist."
PRINT "A value greater than zero means that the key doesn't exist."
PRINT "A value less than zero means that the value name doesn't exist."
PRINT
PRINT "Status Key: Software\Chevy Value Name: Engine"; REGEXIST(HKLM,"Software\Chevy", "Engine")
PRINT
PRINT "Creating key."

CREATEREGINT(HKLM, "Software\Chevy", "Engine", 350)

PRINT "Status Key: Software\Chevy Value Name: Engine"; REGEXIST(HKLM,"Software\Chevy", "Engine")
PRINT "Value for Key: Software\Chevy Value Name: Engine"; REGINT(HKLM,"Software\Chevy", "Engine")
PRINT

PRINT "Changing key. "

CREATEREGINT(HKLM, "Software\Chevy", "Engine", 283)

PRINT "Status Key: Software\Chevy Value Name: Engine"; REGEXIST(HKLM,"Software\Chevy", "Engine")
PRINT "Value for Key: Software\Chevy Value Name: Engine"; REGINT(HKLM,"Software\Chevy", "Engine")
PRINT
PRINT "Deleting key."

DELETEREGKEY(HKLM, "Software\Chevy")

PRINT "Status Key: Software\Chevy Value Name: Engine"; REGEXIST(HKLM,"Software\Chevy", "Engine")

PAUSE

Result:

A zero value means that the key and value name exist.
A value greater than zero means that the key doesn't exist.
A value less than zero means that the value name doesn't exist.

Status Key: Software\Chevy Value Name: Engine 2

Creating key.
Status Key: Software\Chevy Value Name: Engine 0
Value for Key: Software\Chevy Value Name: Engine 350

Changing key.
Status Key: Software\Chevy Value Name: Engine 0
Value for Key: Software\Chevy Value Name: Engine 283

Deleting key.
Status Key: Software\Chevy Value Name: Engine 2