new_registry

CRegistry Class Description


The CRegistry class manages saving and retrieving data using the Windows Registry. The Windows Registry is a large database where Windows stores its configurations and information for software like Mira. You can use this feature to save and retrieve information used in scripts.

The registry is organized to hold values inside keys. The keys are organized in a hierarchical structure containing other keys. Values exist in the registry as keyword-value pairs in which the keyword identifies the information help in the value. For example, sWindowName="My_Name" is an example of a Registry value in which sWindowName is the keyword that identifies the information and "My_Name" is the actual data held by the value.

Information stored by the CRegistry class exists as keywords below the following level of the Windows Registry:

     HKEY_CURRENT_USER\Software\Mirametrics\Mira\Params

A registry key must be opened to access (save, retrieve, or delete) keyword-value pairs under the key. For example, using the key named "MyKey" above, the two registry value sWindowName="My_Name" andnPlotIndex=2 would be saved as follows:

     HKEY_CURRENT_USER\Software\Mirametrics\Mira\Params\MyKey\sWindowName="My_Name "

     HKEY_CURRENT_USER\Software\Mirametrics\Mira\Params\MyKey\nPlotIndex=2

To access these values, open the key "MyKey" and the use class methods to access the values using the keyword of the keyword-value pairs. The locationHKEY_CURRENT_USER\Software\Mirametrics\Mira\Params should never be specified.

Registry keywords are always strings. Registry values available to the CRegistry class have the following types:

bullet.gif    integer

bullet.gif    real

bullet.gif    string

bullet.gif    boolean

bullet.gif    RGB

These values are set or retrieved using by specifying the key and value name in the appropriateGet...() and Set...() methods included in this class.

Working with a Registry Key

Working with the CRegistry class is straightforward:

bullet.gif    Create a CRegistry object using new_registry or CRegistry:new constructor or use the CRegistry:Open method. If a key name is passed as a parameter, the key is opened for use. If no parameter is passed to new_registry or new, the method must be followed by passing the registry key as a parameter to CRegistry:Open.

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 the CRegistry object using the delete or Close method.

bullet.gif    To permanently delete a registry key, use DeleteKey.

bullet.gif    To permanently delete a registry value, use DeleteValue.

Usage

Construction

Object = new_registry( sKeyName )

 

Object = CRegistry:new( sKeyName )

Object = CRegistry:Open( sKeyName )

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. Pass either the key name string or another CRegistry object to automatically open the registry key.

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

Deletes the CRegistry object. Same as Close.

Close

Deletes the CRegistry object. Same as delete.

DeleteKey

Deletes a registry key and all its subkeys and values.

DeleteValue

Deletes a registry value inside a key

Operations

GetBool

Returns a Boolean (true or false) value

SetBool

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

GetInt

Returns an integer value.

SetInt

Sets a keyword (name) to an integer value.

GetNum

Returns a numeric (real number) value.

SetNum

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

GetRgb

Returns an RGB string value.

SetRgb

Sets a keyword (name) to an RGB string value

GetStr

Returns a string value

SetStr

Sets a keyword (name) to a string value.

Related Topics

Script Classes

 

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