Registers custom information for developed components.
STDAPI DllRegisterDesigner(
DESIGNERREGINFO *pDri
);
Parameter
pDri
[in] Pointer to a DESIGNERREGINFO structure with the following members:
Member | Contents |
cb | A ULONG value specifying the size of the structure. Must be sizeof(DESIGNERREGINFO). |
pszProgID | An LPCOLESTR value specifying the programmatic ID (PROGID) of the object being registered. |
clsid | A CLSID value specifying the class ID of the object being registered. |
guidTypeLib | A GUID value specifying the type library ID of the object being registered. |
wVerMajor | A WORD value specifying the major version number of the object being registered. |
wVerMinor | A WORD value specifying the minor version number of the object being registered. |
rgbRegInfo | An array of bytes previously returned by IDesignerRegistration::GetRegistrationInfo. Contains NULL if the designer does not implement IDesignerRegistration. |
Return Value
An HRESULT value indicating success or failure.
Comments
The designer implements DllRegisterDesigner. Support for DllRegisterDesigner is optional. Designers that need to register custom information for developed components can do so with this routine. A designer that implements this API must set DESIGNERFEATURE_REGISTRATION in the registry.
The host automatically registers default information for a designer, including its ProgId, CLSID, and Typelib ID keys. After registering the default information, the host calls the designer's DllRegisterDesigner API if the designer sets DESIGNERFEATURE_REGISTRATION in the registry.
DllRegisterDesigner is similar to DllRegisterServer (see the COM Programmer’s Reference in the Platform Software Development Kit for details), except that DllRegisterDesigner registers information for only a single class. The host calls DllRegisterDesigner once for each authored designer object in the project. For example, if the user creates two public run-time objects (MyObj1 and MyObj2), the host calls DllRegisterDesigner twice.
In the rgbRegInfo member of the pDri parameter, the host passes the same data it previously received through a call to the designer's IDesignerRegistration::GetRegistrationInfo method. A designer can use the rgbRegInfo structure to pass an array of bytes from its design-time instance to its run-time instance. Designers that allow the user to make design-time choices that affect registration should implement IDesignerRegistration and use this parameter to pass the necessary information.
DllRegisterDesigner must be implemented in the DLL that implements the designer's run-time object.
Example
The following example implements DllRegisterDesigner for a designer that registers the authored class CATID_SHAPES. When the host calls the API, it passes the class ID, programmatic ID (prog ID), and type library ID of the new class. However, the host does not pass information in the rgbRegInfo array, because the designer does not implement IDesignerRegistrationInfo::GetRegistrationInfo. The designer can register this object without requiring additional information from the user at design time.
STDAPI DllRegisterDesigner
(
DESIGNERREGINFO * pdri
)
{
HRESULT hr;
char szDescription[] = "Shapes Object Support";
OLECHAR* pwzDesc = NULL;
ICatRegister* pcr = NULL;
CATID rgcatid[1];
// Verify inputs.
if ( pdri == NULL )
return E_INVALIDARG;
// Set pdri->rgbRegInfo to NULL since we do not
// implement IDesignerRegistration.
pdri->rgbRegInfo = NULL;
// Create a component category for SHAPES in the
// registry.
pwzDesc = OLESTRFROMANSI(szDescription);
hr = CreateComponentCategory(CATID_SHAPES, pwzDesc);
RETURN_ON_FAILURE(hr);
// Register our support for CATID_SHAPES.
hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr,
NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr);
// If we created an instance, register the category as being
// "implemented" by the class.
if (SUCCEEDED(hr)){
rgcatid[0] = CATID_SHAPES;
hr = pcr->RegisterClassImplCategories(pdri->lsid, 1, rgcatid);
}
if( pcr != NULL )
pcr->Release();
return hr;
}
See Also
DllUnregisterDesigner, IDesignerRegistration, DESIGNERFEATURE_REGISTRATION