7.1.1 Structure of the Database

The registration database is stored in binary format in a file named REG.DAT. This file is saved in the user's Windows directory.

Data in the registration database is in the form of a hierarchically structured tree. Each node in the tree is identified by a key name. Each key name is a string from the set of printable ASCII characters (values 32 through 127). Key names cannot include a space, a backslash (\), or a wildcard (* or ?). Key names beginning with a period (.) are reserved.

Any key name can also be associated with a text string that provides further information about that key. The text string can contain any character from the set of printable ASCII characters. These text strings are also called values.

Each key name is unique with respect to the key that is immediately above it in the hierarchy. For example, the open and print keys are often subkeys of the key named shell. Both open and print might have subkeys named command, but open could not have two subkeys named command.

The system defines a standard entry for the root level of the database: HKEY_CLASSES_ROOT. Root-level key names that begin with a period are reserved by the system. Database entries that are subordinate to the HKEY_CLASSES_ROOT key define types (or classes) of documents and the properties that are associated with these classes. Information stored under HKEY_CLASSES_ROOT is used by Windows shell applications and by OLE applications.

The following table shows the structure of a typical REG.DAT file. In this table, bold characters designate reserved words and italic characters designate words or phrases that vary with the registering application.

Key Text string

HKEY_CLASSES_ROOT ,  
.ext class name
ClassName class description
shell ,  
open ,  
command, command line to open application  
ddeexec, DDE command used when opening document  
application, DDE application name to start conversation  
topic, topic of the DDE conversation  
ifexec, DDE command if conversation does not start  
print ,  
command, command line to open application  
ddeexec, DDE command used when printing document  
application, DDE application name to start conversation  
topic, topic of the DDE conversation  
ifexec, DDE command if conversation does not start  
protocol ,  
StdFileEditing ,  
server, command line for opening application  
handler, path and filename for handler DLL  
verb, any verb  

Future versions of the database will include more reserved words. To avoid conflict with future versions, applications should record information that is not used by the Windows shell or OLE in private initialization files.

Standardized keys help an application navigate in the database. When an application has found the key for a feature, it typically uses the text string associated with that key. (As shown in the preceding list, however, not all keys have text strings.) For example, if an application needs to display the name of an application in a dialog box, the application might use the ClassName key to find the class description text string. The class name is often an abbreviated string, for application use only, whereas the class description is the full name of the application and is presented in the user interface.

Some standard entries to the database that are occasionally used by OLE server applications are not noted in the preceding list. For more information about these standard entries, see Chapter 6, “Object Linking and Embedding Libraries.”

The following illustration shows how Windows Paintbrush is registered in REG.DAT (as displayed when REGEDIT.EXE is started with the /v option).