CRegistry Class Description
The CRegistry class manages saving and retrieving data using the Windows Registry. This is the same technique used by software applications to manage their configuration data and other settings. The CRegistry class uses a registry key name to access a Registry location where the data are stored. Individual data values are stored by a (name, value) pair under the key. You can create your own script keys or work with Mira's internal program keys (i.e., keys not created by a script) that control Mira dialogs and commands. Manipulating Mira's internal registry keys can be a powerful asset to scripting but must be done with care.
Keys are stored in the following registry section:
HKEY_CURRENT_USER\Software\Mirametrics\Mira\Params
The registry section cannot be changed. For example a key named "My Key" would be stored at
HKEY_CURRENT_USER\Software\Mirametrics\Mira\Params\My Key
Beneath the key are any number of named values have any of the following data types: integer, real, string, Boolean, or RGB. Values are accessed by name using one of the Get,,,() or Set,,,() methods provided by the CRegistry class.
Note that saving script keys in the ...\Params registry section allows access to Mira's internal keys while allowing the risk of colliding with an internal Mira key of the same name. To reduce the risk of accidental name collision, it is recommended that script key names begin with some prefix name, like "(Script)". Moreover, using a key name starting with a "(" character causes the key to be stored at the beginning of the ...\Params section of the Windows Registry where you can easily find it when viewing the registry using the Windows Registry Editor.
Working with the CRegistry class is straightforward:
Open an existing key or create a new key by passing a name in the new() or Open() method.
Read values from the open key using one of the Get...() methods.
Save values to the open key using one of the Set...() methods.
When finished using a key, close it using the delete() or Close() method.
To permanently delete a key from the registry, use DeleteKey().
Construction and destruction may be dine using either of two equivalent pairs of constructors and destructor name. Most Pro Script classes, including CRegistry, use the new / delete pair to construct and destroy an instance of a CRegistry object. For this class, the Open / Close methods are also included simply as alternative names that parallel the notion of opening and closing a registry key.
Construction |
Object = CRegistry:new( sName ) Object = CRegistry:Open( sName ) |
Destruction |
Object:delete() Object:Close() |
Opens a key by creating a new CRegistry object that is an instance of the CRegistry class. Same as Open. |
|
Opens a key by creating a new CRegistry object that is an instance of the CRegistry class. Same as new. |
|
Closes a key by deleting the CRegistry object. Same as Close. |
|
Closes a key by deleting the CRegistry object. Same as delete. |
Returns a Boolean (true or false) value |
|
Sets a key to a Boolean (true or false) value. |
|
Returns an integer value. |
|
Sets a key to an integer value. |
|
Returns a numeric value (in general, a real number). |
|
Sets a key to a numeric (real number) value. |
|
Returns an RGB string value. |
|
Sets a key to an RGB string value. |
|
Returns a string value |
|
Sets a key to a string value. |
|
Returns the handle of a GUI window. |
|
Sets a key to the handle of a GUI window. |