|
||
WARNING and NOTICE of Zero Liability
This class is used by the ProSeries tools and has been tested (in its unaltered state) to be safe to read/write data from the System Registry. While you are allowed to use the class in other parts of your program, YOU are responsible for using the correct settings for root keys, sub keys and values.
We assume ZERO LIABILITY for any damage that you do to your own computer (or those of your clients) as a result of using this class code beyond the bounds of the ProSeries tool that it came with.
USE AT YOUR OWN RISK!!
Note: The registry class is not available in C55 and is automatically disabled in that version of Clarion
If you are using the Registry storage method, here are examples of how to use the class.
Remember that the global extension template takes care of the initialization process for you, but you can also reinitialize on the fly to use a different file or key.
Hint: Once initialized, the class will use whatever INI file you have specified until you reinitialize it with a new value.
Here is an example of a hand coded initialization for an INI file:
DATA
RIC RegINIClass
CODE
RIC.Init( 'Registry', 'LOCAL_MACHINE', 'SOFTWARE\MyApplication' )
In the Init, the Registry string tells the class to use the Registry method of storage.
This example would initialize the class to the Registry mode of storage and to use HKEY_LOCAL_MACHINE as the root registry key with SOFTWARE\MyApplication as the subkey.
The class options you can use to specify the root key are:
ROOT equates to the Clarion registry class expectation of REG_CLASSES_ROOT
CURRENT_USER equates to the Clarion registry class expectation of REG_CURRENT_USER
LOCAL_MACHINE equates to the Clarion registry class expectation of REG_LOCAL_MACHINE
USERS equates to the Clarion registry class expectation of REG_USERS
PERFORMANCE_DATA equates to the Clarion registry class expectation of REG_PERFORMANCE_DATA
CURRENT_CONFIG equates to the Clarion registry class expectation of REG_CURRENT_CONFIG
DYN_DATA equates to the Clarion registry class expectation of REG_DYN_DATA
The subkey is whatever valid subkey string you specify.
Hint: Whatever you specify as the subkey is concatenated with whatever you pass in the GetData and PutData methods as the "Section"
Example:
If you specify the subkey as: SOFTWARE\MyApplication
Then issue a call to PutData as:
RIC.PutData( 'Registered User', 'User Name', 'John Doe' )
Then the class would create a subkey of SOFTWARE\MyApplication\Registered User with an entry called User Name and it would have a value of John Doe.
Writing and reading data from the Registry takes the same syntax as you are used to with the standard Clarion GetINI and PutINI statements - except that the last parameter (the filename) is optional (and totally ignored by the RegINIClass).
The big difference in using the Registry and using an INI file is that entries in the registry are based under the root key and subkey that you specify.
Hint: This means you can convert the rest of your program to use the registry for storage by doing two simple Search/Replace statements.
Search for GetINI and replace it with RIC.GetData
Search for PutINI and replace it with RIC.PutData
This assumes you are using the global extension template which declares the instance of the class as RIC or have used the same name in your declaration.
Writing data to the Registry storage method
The syntax is:
RIC.PutData( Section, Entry, Value, <filename> )
Remember that <filename> is ignored by the class and is only there for backwards compatibility.
Reading data from the Registry storage method
The syntax is:
RIC.GetData( Section, Entry, Value )
You can also delete a value from the Registry (or the entire subkey).
VERY IMPORTANT!
VERY IMPORTANT!
VERY IMPORTANT!
VERY IMPORTANT!
Changes to the System Registry are immediate and irreversible!
Changes to the System Registry are immediate and irreversible!
Changes to the System Registry are immediate and irreversible!
Changes to the System Registry are immediate and irreversible!
Now that we have your attention - BE VERY CAREFUL at where you set the root key and subkey!
While Windows will protect you from deleting or changing some entries based on your user rights, if you (or your customer) are logged in as Administrator - you can render your system inoperable if you make a bad decision.
This is especially true if you are deleting data from the registry. If you get careless and set the subkey wrong or delete from a "common" area used by multiple programs on your system - the results can be disastrous!
It is a good idea to set a system restore point and/or use some utility to backup the registry BEFORE you start development
Deleting a value from the Registry storage method
The syntax is:
RIC.DeleteData( Section, Entry )
Deleting an entire section from the Registry storage method
The syntax is:
RIC.DeleteData( Section )