An Example of Registering a File Viewer

Let's look at an example of registering a file viewer for text (TXT) files. The viewer is implemented in an in-process server DLL called MFCVIEW.DLL, whose class identifier is e83b63c0-6ff5-11ce-993c-00aa004adb6c. The actual Registry entries appear in the REG file shown here:

REGEDIT4

[HKEY_CLASSES_ROOT\CLSID\{e83b63c0-6ff5-11ce-993c-00aa004adb6c}]
@="Nancy's Viewer"
[HKEY_CLASSES_ROOT\CLSID\{e83b63c0-6ff5-11ce-993c-00aa004adb6c}
\InprocServer32]
@="c:\\windows\\system\\viewers\\mfcview.dll"
"ThreadingModel"="Apartment"

[HKEY_CLASSES_ROOT\QuickView\.TXT]
@="txtfile"
[HKEY_CLASSES_ROOT\QuickView\.TXT\{e83b63c0-6ff5-11ce-993c-
00aa004adb6c}]
@="Nancy's Viewer"

[HKEY_CLASSES_ROOT\txtfile\CLSID]
@="{e83b63c0-6ff5-11ce-993c-00aa004adb6c}"

The first line, REGEDIT4, specifies that the registration file follows a new (Windows 95) syntax. Notice the syntax of the entries, with square brackets ( [ ] ) surrounding each key and each value enclosed in quotation marks. This syntax allows you to specify the InprocServer32 and ThreadingModel subkeys. The threading model in this code is set to Apartment, which specifies that multiple threads in the executable can create OLE objects. (Although long lines in the REG file above are broken to fit on the printed page, you must enter each one as a single unbroken line. There is no continuation character.)