Set objRX = CreateObject("Stonebroom.RegEx") 'Visual Basic, VBScript var obRX = new ActiveXObject('Stonebroom.RegEx'); // JavaScript etc. Set objRX = Server.CreateObject("Stonebroom.RegEx") 'Active Server PagesOr by referencing it in your programming language's development environment, for example:
Dim objAX As New Stonebroom.RegExNote: If you are using the component with Internet Information Server version 4, you may like to set the 'Run in separate memory space (isolated process)' option on the Virtual Directory page of the Properties dialog for any directories where you have pages that use the RegEx component. This also makes it possible to unload the component on demand without restarting the server.
This returns the 'Default' value of a given subkey from the Registry. Cannot be used to retrieve named values, or within components or ASP pages that run on Windows NT/2000 under certain limited-priviledge system accounts such as that of the anonymous Web user account. Returns an empty string if the value cannot be accessed.
The syntax of the GetRegValue method is:
SubkeyDefaultValue = GetRegValue(RegistryHive, SubKeyString)
Parameter
Description
RegistryHive
Required. Long Number. The section of the Registry to access. Must be one of the Registry Hive named constants listed below.
SubKeyString
Required. String. The full path excluding the 'hive' name of the subkey to be accessed, for example ControlPanel\Desktop\WindowMetrics.
This updates the 'Default' value within the specified subkey, setting the data-type to REG_SZ (String). Cannot be used to update named values, or within components or ASP pages that run on Windows NT/2000 under certain limited-priviledge system accounts such as that of the anonymous Web user account. Returns True if the update is successful, or False otherwise. The syntax of the SetRegValue method is:
Success = SetRegValue(RegistryHive, SubKeyString, NewValue)
Parameter
Description
RegistryHive
Required. Long Number. The section of the Registry to access. Must be one of the Registry Hive named constants listed below.
SubKeyString
Required. String. The full path excluding the 'hive' name of the subkey to be accessed, for example ControlPanel\Desktop\WindowMetrics.
NewValue
Required. String. The new value to be placed in the subkey as the 'Default' value of that subkey. Stored as a String data-type. If the subkey does not exist it is created automatically.
This returns a named value from the specified subkey, updating the variable specified in the last parameter of the method with the data-type of the returned value. When used with Windows NT/2000, the method requires that the target Registry subkey have at least READ permission set for the account under which the component or ASP page is running. Returns an empty string, and REG_ERROR as the data-type, if the value cannot be accessed. The syntax of the GetRegValueEx method is:
SubkeyNamedValue = GetRegValueEx(RegistryHive, SubKeyString, ValueName, ValueType)
Parameter
Description
RegistryHive
Required. Long Number. The section of the Registry to access. Must be one of the Registry Hive named constants listed below.
SubKeyString
Required. String. The full path excluding the 'hive' name of the subkey to be accessed, for example ControlPanel\Desktop\WindowMetrics.
ValueName
Required. String. The name associated with the value to be returned. This name identifies the value and acts as the key when other functions retrieve or update it.
ValueType
Required. Long Variant. Updated on return with the data-type of the named value as one of the Data Type named constants listed below.
This updates a named value within the specified subkey, setting the data-type to that specified in the last parameter of the method. When used with Windows NT/2000, the method requires that the target Registry subkey have ALL ACCESS permission set for the account under which the component or ASP page is running. Returns True if the update is successful, or False otherwise. The syntax of the SetRegValueEx method is:
Success = SetRegValueEx(RegistryHive, SubKeyString, ValueName, NewValue, ValueType)
Parameter
Description
RegistryHive
Required. Long Number. The section of the Registry to access. Must be one of the Registry Hive named constants listed below.
SubKeyString
Required. String. The full path excluding the 'hive' name of the subkey to be accessed, for example ControlPanel\Desktop\WindowMetrics.
ValueName
Required. String. The name to be associated with this value. Used to identify the value and acts as the key when other functions retrieve or update it.
NewValue
Required. Variant. The new value to be placed in the subkey as a named value of that subkey. If the subkey or named value does not exist it is created automatically.
ValueType
Required. Long Number. The data-type to be used when storing the named value in the Registry. Must be one of the Data Type named constants listed below, excluding REG_ERROR and REG_NONE.
This returns the internal version number of the component. If it is an evaluation version, the return value will contain this information as well. The GetInternalVersionNumber method takes no parameters, and returns a String. The syntax is:
VersionString = GetInternalVersionNumber()
The structure of the Windows Registry has evolved over time, and now contains two different types of subkey values. This is why two different sets of methods can be used to access values. The original type of subkey had only a single value, which was always of type String. This emulated the earlier technique of using disk-based INI text files to store information.
In 32-bit Windows, the registry changed to offer multiple-value subkeys. In this case, each subkey can store a single value as the default value of the subkey (providing compatibility with the earlier structure of the Registry, plus any number of other values that are each identified by a unique name:
The 'Default' value can be accessed using the simple Registry methods GetRegValue and SetRegValue, and always contains a String-type value. However, the security settings applied to the registry by default generally prevent components running under service accounts (for example those used in ASP on a Web server) to access the registry. In contrast, the named values can always be accessed using the extended registry access methods GetRegValueEx and SetRegValueEx. The named values can store data in different formats. The extended RegEx access methods accept extra parameters for the value name and the data type.
Registry Security Issues
In Windows NT/2000, the individual subkeys in the Registry can have Permissions allocated to them, controlling which accounts can access each subkey and what actions they can take (i.e. Read, Write, Enumerate Subkeys, Create Subkey, etc.). The GetRegValue and SetRegValue methods do not provide any security information when attempting to access the Registry, and so should be avoided in Windows NT/2000. Instead, use the extended methods GetRegValueEx and SetRegValueEx.
The GetRegValueEx method attempts to open the subkey for READ access only, so will succeed when the subkey has Read and Enumerate Subkeys permissions set for the account under which the component or ASP page is running. The SetRegValueEx method attempts to open the subkey for ALL ACCESS, and so will only succeed if the account has Read, Write, Enumerate Subkeys and Create Subkey permissions set for this subkey.
These named constants identify the individual 'hive' or section of the Registry in which the value is stored. They are used with all four access methods of the component: GetRegValue, SetRegValue, GetRegValueEx and SetRegValueEx.
Name
Value
Description
HKEY_CLASSES_ROOT
0
Stores information about the types of files and objects that are installed, such as the class strings (CLASSIDs), and the association between applications and files. Can also be accessed via HKEY_LOCAL_MACHINE\Software\Classes.
HKEY_CURRENT_USER
1
Stores information about the configuration for the currently logged-on user, and is updated each time a different user logs in.
HKEY_LOCAL_MACHINE
2
Stores information that is concerned with the computer rather than the currently logged-on user. Windows NT services use this key when operating under a system account with no logged-on user.
HKEY_USERS
3
Stores the default configuration information for existing and new users, plus subkeys for each known user containing the changes they made to their own default settings.
HKEY_PERFORMANCE_DATA
4
Used in Windows NT/2000 to hold data that does not need to be persisted between users or sessions, such as information on the performance of the system and current user statistics.
HKEY_CURRENT_CONFIG
5
Used in Windows 9x to store system configuration information. Can also be accessed via HKEY_LOCAL_MACHINE\Config\{number}.
HKEY_DYN_DATA
6
Used in Windows 9x to hold data that does not need to be persisted between users or sessions, such as information on the performance of the system and current user statistics.
These named constants identify the internal data type that the value is stored in. They are used only with the extended methods of the component: GetRegValueEx and SetRegValueEx.
Name
Value
Description
REG_ERROR
-1
Error while processing request
REG_NONE
0
No value type specified
REG_SZ
1
Unicode null-terminated string
REG_EXPAND_SZ
2
Unicode null terminated unexpanded environment string
REG_BINARY
3
Free form binary
REG_DWORD
4
32-bit number in default numeric format
REG_DWORD_LITTLE_ENDIAN
4
32-bit number - same as REG_DWORD
REG_DWORD_BIG_ENDIAN
5
32-bit number stored with reversed bytes
REG_LINK
6
Symbolic Link (unicode string without terminating ASCII zero)
REG_MULTI_SZ
7
Multiple unicode strings separated by ASCII zero characters and ending with two ASCII zero characters
REG_RESOURCE_LIST
8
Resource list in the resource map
REG_FULL_RESOURCE
_DESCRIPTOR9
Resource list in the hardware description
REG_RESOURCE
_REQUIREMENTS_LIST10
Resource requirements description
©1999 Stonebroom Software, UK