For most applications, the developer creates a registration (.REG) file that con-tains the database entries. Registration Editor (REGEDIT.EXE) can then be used to merge the .REG file into the user's REG.DAT file when the application is installed on the user's system.
The following example shows the format of a .REG file that would set up Microsoft Paintbrush with the entries shown in Figure 7.1:
REGEDIT
This is a comment line.
HKEY_CLASSES_ROOT\PBrush = Paintbrush Picture
HKEY_CLASSES_ROOT\.bmp = PBrush
HKEY_CLASSES_ROOT\.msp = PBrush
HKEY_CLASSES_ROOT\.pcx = PBrush
HKEY_CLASSES_ROOT\PBrush\shell\print\command = pbrush.exe /p %1
HKEY_CLASSES_ROOT\PBrush\shell\open\command = pbrush.exe %1
HKEY_CLASSES_ROOT\PBrush\protocol\StdFileEditing\verb\0 = Edit
HKEY_CLASSES_ROOT\PBrush\protocol\StdFileEditing\server = pbrush.exe
The first line of the file must be REGEDIT, as shown. Any subsequent lines that do not begin with HKEY_CLASSES_ROOT are currently treated as com-ments by REGEDIT.EXE. For compatibility with future versions of the database, however, a comment should not begin with a backslash (\) character or with the string HKEY. Each line to be added to the database must begin with a full key name. To create a key with an associated text string, the key name must be followed by at least one space, an equal sign (=), another space, and the string. Characters following the equal sign and single space are treated as the value of the key.
When SHELL.DLL encounters the string %1 in a command, it replaces that string with the name of the document being opened or printed.
A .REG file cannot be larger than 64K.
The setup procedure for the registering application typically merges this file with the user's REG.DAT file by running REGEDIT.EXE with the /s option. (Applications that must update the database with Windows 3.0 can use REGLOAD.EXE instead of REGEDIT.EXE to merge the files. REGLOAD.EXE is smaller than REGEDIT.EXE and does not require the common dialog box dynamic-link library COMMDLG.DLL.)