There are four classes to get familar with when using the EasyReg component. They all map to the structures in the system registry:
The only class which can be created is the RegNode class. This is always the
class you start with.
From the RegNode class you can the work your way down the registry structures,
querying for attached values and the sub-nodes attached to the current node.
You use the Set method in the RegNode class to point to a specific reistry key. This will initialize the class and you will be able to query the node for subnodes and values.
The RegNodes and RegValues classes are collection classes. They are handed to the caller when the Nodes and Values methods are called on the RegNode class.
Finally the RegValue class represents an actual registry value. It has two properties, Name and Value. The Name property, naturally, returns the name of the value, while the Value property returns the actual value. The value may be a number or a text, so the data type may vary.
You can use the collection classes, RegNodes and RegValues, to add and delete registry entries. Using the Add and Remove methods it is possible to build your own registry structures.
A typical example for a EasyReg session:
|
This sample uses the new keyword to create a new RegNode class.
It is also possible to use the CreateObject statement is Visual Basic.
The new RegNode class is then initialized and set to the
"HKEY_CURRENT_USER\SOFTWARE\Baan\BaanConfiguration" registry key. From
there we locate the "MediaPath" registry value and print out the
value.
When working in a scripting language, such as MS Visual Basic, you always need to consider performance as an important factor of application development. This is especially true when working with collections.
In short, you should not do the following:
|
but rather write...
|
because the latter will only make one reference to each of the collection objects, while the first sample would query and recreate the entire collection each time a value is looked up. Needless to say, that only creating the collections once results in much faster execution.