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 a Registry Key

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().

Usage

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()

Methods

Construction & Destruction

new

Opens a key by creating a new CRegistry object that is an instance of the CRegistry class. Same as Open.

Open

Opens a key by creating a new CRegistry object that is an instance of the CRegistry class. Same as new.

delete

Closes a key by deleting the CRegistry object. Same as Close.

Close

Closes a key by deleting the CRegistry object. Same as delete.

Operations

GetBool

Returns a Boolean (true or false) value

SetBool

Sets a key to a Boolean (true or false) value.

GetInt

Returns an integer value.

SetInt

Sets a key to an integer value.

GetNum

Returns a numeric value (in general, a real number).

SetNum

Sets a key to a numeric (real number) value.

GetRgb

Returns an RGB string value.

SetRgb

Sets a key to an RGB string value.

GetStr

Returns a string value

SetStr

Sets a key to a string value.

GetWnd

Returns the handle of a GUI window.

SetWnd

Sets a key to the handle of a GUI window.

Related Topics

Script Classes