Registration Database Operations

 

In the early days of Windows, there was a single INI file, WIN.INI. As Windows advanced, the WIN.INI file became cluttered, and it was then subdivided into SYSTEM.INI, WIN.INI and a large number of application specific INI files.

With the advent of COM/OLE, Windows NT, and other advancements in operating system technology, the simple INI files could not hold or organize the new and vast amounts of information required to run a modern operating system. For this reason, a new data storage structure was developed. Sometimes called the Registry or the Registration Database, this new file was designed to be able to hold and organize large amounts of seeming random information.

The Registration Database is organized in a tree structure, much like a file system. At every level "keys" to the data exist. The keys are analogous to the sub-directories in a file system. A set of keys to a data item look very much like a path to a filename.

In Windows, the Registration Database may be viewed and altered with the "RegEdit" utility. It requires a "/v" parameter, as in "regedit.exe /v", to enable the edit mode of the utility. In Windows NT+, there exists the "RegEdt32" utility that allows access to the Registration Database.

CAUTION: The reason that these utilities are not made easily accessible is that it is trivially easy to make a modification to the database that will completely ruin a Windows installation, and may require a complete re-install of the Windows version to get the system running again. It is best to study the database and understand what is going on, instead of perhaps using a somewhat common "trial and error" method of making changes.

There are two ways to query and set information in the Registration Database. The easy way is to simply base all operations on an always open root key. Using just the RegQueryValue and RegSetValue functions you can alter all data associated with pre-defined keys.

The other more complicated and more flexible method is to open or create a desired key, using the RegOpenKey or RegCreateKey functions, modify the database with other registration functions, passing it a handle to the key, and then finally close the database with the RegCloseKey function.

Most of the registration functions accept both a handle to a key and a subkey string which further defines a lower key. Oftentimes the subkey string is simply set to null (empty quotes), and the handle points directly to the destination. At other times, one of the pre-defined roots of the database is passed as the handle and the subkey string points all the way down to the desired data item.

Registry symbolic link keys are an advanced feature of the Windows registration database. They can be used to support older versions of registry dependent scripts and executables when migrating to new to registry key names. For example, a company might change its name and has software that is dependent on keys that bear the old company name. The RegCreateKeyEx, RegSetEx, RegCloseKey, and RegDeleteLink functions support the creation and removal of registration database symbolic links.

Pre-defined keys are provided. Windows provides several keys, as shown in the table below:

32 bit Windows handles to always open keys

@REGMACHINE Root of the machine section of the Registration Database. HKEY_LOCAL_MACHINE

@REGCLASSES Shortcut to the classes sub-section. HKEY_CLASSES_ROOT

@REGUSERS Root of the user section of the Registration Database. HKEY_USERS

@REGCURRENT Shortcut to the current user’s sub-section. HKEY_CURRENT_USER

@REGCLASSES+5 Shortcut to the current config sub-section. HKEY_CURRENT_CONFIG

 

Note: Named data entries as found in Windows are specified by enclosing the "data item name" in square brackets at the end of the key string. For Example:

 

RegSetValue( @REGMACHINE,"SOFTWARE\Wilson WindowWare\Settings\WWWBATCH\MAIN[SOUNDS]",1)

 

Use [] to refer a '(Default)' data item under a specified key. For Example:

 

;this example gets the DEFAULT value under a specific key

ret = RegQueryValue( @REGCLASSES, "txtfile[]" )

message( "Value of default key", ret )