Registering an ActiveX Designer

ActiveX designers provide the DLLRegisterServer and DLLUnregisterServer entry points for use with the registry. DLLRegisterServer stores information about the visual designer and run-time object in the registry. DLLUnregisterServer removes information from the registry.

Registering an ActiveX designer is much like registering an ActiveX control. With the following exceptions, designers register the same information as controls:

ActiveX designers register with Component Categories, using the ICatRegister interface. 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. You use the RegSetValue API for this task, as the following example shows:

l = RegSetValue (HKEY_CLASSES_ROOT, szInstanceInfo, REG_SZ, szInstCLSID,
                 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 give 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 szInstCLSID [] = "{fdc139b0-9800-11cf-a0d2-00aa0062be57}";

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

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

Including the information registered by ActiveX controls, designers must register the following:

Under the MiscStatus key, the DVASPECT flag should be 1, to indicate DVASPECT_CONTENT. If the run-time object does not have a visual interface, you should include OLEMISC_INVISIBLEATRUNTIME with the miscellaneous status flags.