Designer-Specific Registry Requirements

All designers register CATID_Designer in the Implemented Categories subkey of the CLSID key. The value of CATID_Designer is defined in the header file Designer.h and in Designer.idl.

The following additional registry entries are specific to ActiveX designers:

ActiveX designers register with Component Categories, using the ICatRegister interface. See the COM Programmer’s Reference in the Platform Software Development Kit (SDK) for details on the registry interfaces and related APIs.

The following example registers CATID_Designer and the designer's CLSID:

hr = CoCreateInstance (CLSID_StdComponentCategoriesMgr, NULL,
   CLSCTX_INPROC_SERVER, IID_ICatRegister,
   (void **)&pCatRegister);
if (SUCCEEDED(hr)) {
   pCatRegister->RegisterClassImplCategories(
      CLSID_DifferentDesigner, 1, (GUID *)&CATID_Designer);
    pCatRegister->Release();
};

The example calls CoCreateInstance to create an instance of the component categories manager and get pCatRegister, a pointer to the ICatRegister interface. It then calls the RegisterClassImplCategories method, passing the CLSID of the designer and CATID_Designer, to register the designer under the Implemented Categories subkey. Finally, the example releases its reference to the ICatRegister interface.

In addition, if the run-time object is different from the visual designer, its CLSID must be registered under the Instance CLSID subkey of the CLSID key. Use the RegSetValue API for this task, as in the following:

lStatus = RegSetValue (HKEY_CLASSES_ROOT, szInstanceInfo, REG_SZ, 
             szInstanceCLSID, sizeof(szInstCLSID));

In the example, HKEY_CLASSES_ROOT indicates where the information should be stored. The REG_SZ parameter denotes the type of information being supplied, and must always be REG_SZ. The szInstanceInfo and szInstanceCLSID parameters specify the subkey and the value to be stored for it. In the example, these parameters have been defined to contain the Instance CLSID subkey and the CLSID of the run-time object, as follows:

static char szInstanceInfo [] = 
   "CLSID\\{d342aea0-97d0-11cf-a0d2-00aa0062be57}\\Instance CLSID";
static char szInstanceCLSID [] = 
   "{fdc139b0-9800-11cf-a0d2-00aa0062be57}";

The function returns lStatus, a long integer indicating success or failure.

If the designer sets one or more flags under the DesignerFeatures key, it must create the key and set the flags as in the following example. Error handling has been omitted for brevity.

static char szDesignerFeatures[]  =
  " CLSID\\{12345ABC-D67E-89F0-9876-55E44DC3B210}\\DesignerFeatures"; 
HKEY hkey;
   lStatus = RegCreateKey(HKEY_CLASSES_ROOT, szDesignerFeatures, &hkey);

   DWORD dwValue = 
      DESIGNERFEATURE_CANBEPUBLIC | DESIGNERFEATURE_CANCREATE;

   lStatus = RegSetValueEx(hkey, "Required", NULL, REG_DWORD,
          (BYTE*)&dwValue, sizeof(DWORD));
   RegCloseKey(hkey);

In the example, the variable szDesignerFeatures is defined to contain the designer's class ID and the string "DesignerFeatures". The call to RegCreateKey creates this key in the registry under HKEY_CLASSES_ROOT. The call to RegSetValueEx sets the value for the key, specifying the string "Required" and passing in dwValue the DESIGNERFEATURE_CANCREATE and DESIGNERFEATURE_CANBEPUBLIC flags. (See Chapter 11, "Registry Reference," for a complete list of designer features flags.) The call to RegCloseKey closes the registry key to changes.

The example is not licensed. If it were, it would register a license under the Licenses key.