Registering User Interface Extensions

Like all COM objects, user interface extensions must be registered in the Registry, or they won't work. An extension must register its class ID (CLSID) under the Registry key HKEY_CLASSES_ROOT\CLSID. Within this key, the extension adds an InProcServer32 key that gives the location of the extension's DLL. The first statement in the following sample code registers the CLSID of my property sheet extension, NancyPropSheet. The second statement in the code specifies the location of the DLL containing the extension and the threading model:

[HKEY_CLASSES_ROOT\CLSID\{771a9da0-731a-11ce-993c-00aa004adb6c}]
@="NancyPropSheet"
[HKEY_CLASSES_ROOT\CLSID\{771a9da0-731a-11ce-993c-00aa004adb6c}\
InprocServer32]
@="c:\\windows\\system\\propext.dll"
"ThreadingModel"="Apartment"

The shellex key contains the information used to associate a user interface extension with a file type. You must also register your extension under this key. You can map the user interface extension to a particular class of file (based on the filename extension), or you can specify that it is valid for files of all types. To register the property sheet for files of a specific type—NWCFile, for example—specify the file type as shown here:

[HKEY_CLASSES_ROOT\.NWC]
@="NWCFile"
[HKEY_CLASSES_ROOT\NWCFile]
@="Shell Extension file"
[HKEY_CLASSES_ROOT\NWCFile\shellex\PropertySheetHandlers]
@="NWCPage"
[HKEY_CLASSES_ROOT\NWCFile\shellex\PropertySheetHandlers\NWCPage]
@="{771a9da0-731a-11ce-993c-00aa004adb6c}"

If you want all files to reap the benefits of your special property sheet page, specify an asterisk (*) after HKEY_CLASSES_ROOT, as I did in my property sheet handler, PROPEXT:

[HKEY_CLASSES_ROOT\*\shellex\PropertySheetHandlers]
@="NWCPage"
[HKEY_CLASSES_ROOT\*\shellex\PropertySheetHandlers\NWCPage]
@="{771a9da0-731a-11ce-993c-00aa004adb6c}"

NOTE: To remove any of the user interface extensions that are registered by the samples discussed in this chapter, please refer to the \README.TXT file on the companion disc.