Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Toolkit User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

16.8 Win32 Registry Access

Objective Toolkit provides an encapsulation of the Win32 registry APIs. Using Objective Toolkit's registry abstraction, you can modify the registry through a common interface consistent under all supported platforms.

SECRegistry encapsulates the APIs used to access and modify the Windows registry in a single class. The bulk of the SECRegistry methods are wrappers for the Win32 API. One advantage of using the class instead of the Win32 API is that you can recursively delete keys in a 32-bit environment.

16.8.1 The SECRegistry Class

The SECRegistry class encapsulates the Win32 registry API. An SECRegistry instance contains a member handle to a registry key. This same key is then used as a parameter to some of the Windows registry APIs (SECRegistry shields the user from having to keep track of the handle).

Figure 139: Objective Toolkit's Registry Class Hierarchy

16.8.2 Using SECRegistry

The following terms are used in the following descriptions:

Keys. Nodes that can contain one or more keys or values. A key is like a folder that can contain other folders (keys) or items (values).

Values. An item that is contained by a key that has two attributes: a name and an associated evaluation. For example:

Name Value
"Path" "C:\Program Files\WordView\WordView.exe"
"Password" "GX325PF"
Version 5.1

The following section show you how to use SECRegistry to modify registry settings.

16.8.2.1 To open the registry

Call the Connect() method. If a computer name is specified, the application attempts to open the registry remotely. There must be sufficient permissions for remote registry connections to work. For example:

16.8.2.2 To open a subkey

  1. Connect() to the registry.

  2. Open the subkey with the Open() method.

16.8.2.3 To enumerate registry keys

  1. Connect() to the registry.

  2. You can also open a subkey.

  3. Call the EnumerateKeys() method.

16.8.2.4 To enumerate values within a key

  1. Connect() to the registry.

  2. You can also open a subkey.

  3. Call the EnumerateValues() method.

16.8.2.5 To read a value

  1. Connect() to the registry.

  2. You can also open a subkey.

  3. Call one of the following methods to retrieve the value. These methods assume you know the type of the value. See Section 16.8.2.4.

  4. You can also call one of the overloaded GetValue() methods or the QueryValue() method.

16.8.2.6 To create a key

  1. Connect() to the registry.

  2. You can also open a subkey.

  3. Call the Create() method to create the new key.

16.8.2.7 To delete a key

  1. Connect() to the registry and open the parent of the key about to be deleted.

  2. Call the DeleteKey() method to delete a particular subkey.


    DeleteKey() fails if the key being deleted contains subkeys. To delete subkeys, you need to specify a recursive delete operation. See Section 16.8.2.8.

16.8.2.8 To recursively delete keys

  1. Connect() to the registry, and open the parent of the key about to be deleted.

  2. Call the DeleteKey() method to delete a particular subkey and specify a recursive delete.


    Be careful when recursively deleting registry keys!

16.8.2.9 To close a registry connection

Call the Close() method.


If this method is not called explicitly, it is called implicitly by the SECRegistry destructor.

16.8.3 SECRegistry Sample

The Objective Toolkit regdemo sample (Samples\Toolkit\MFC\Utility\regdemo) illustrates how to use SECRegistry in a 32-bit environment. This sample does not ship with the product. For information on how to obtain this sample, see Section 3.6.1, "Location of Sample Code," in the Stingray Studio Getting Started Guide.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.