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 pixel 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:

bullet.gif    Open an existing key or create a new key by passing a name in the new() or Open() method.

bullet.gif    Read values from the open key using one of the Get...() methods.

bullet.gif    Save values to the open key using one of the Set...() methods.

bullet.gif    When finished using a key, close it using the delete() or Close() method.

bullet.gif    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 = new_registry()

Object = CRegistry:new( sName )

Object = CRegistry:Open( sName )

Destruction

Object:delete()

Object:Close()

Creation - Non-class Functions

This function is normally used to create a new CRegistry object as an alternative to the class-based new method.

new_registry

Global function that creates a new CRegistry object.

Construction and Destruction - Class Methods

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

GetInt

Returns an integer value.

GetNum

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

GetStr

Returns a string value

GetRgb

Returns an RGB string value.

SetBool

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

SetInt

Sets a key name to an integer value.

SetNum

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

SetStr

Sets a key name to a string value.

SetRgb

Sets a key name to an RGB string value.

Related Topics

Script Classes


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.