Obtaining a CLSID for a Custom Class

COM objects are created by calling CoCreateInstance() with a CLSID, which identifies the object type. To retrieve the CLSID for a given AcDbObject-derived object, applications use its getClassID() function. Here is the signature for getClassID():

// Get corresponding COM wrapper class ID.
//
virtual Acad::ErrorStatus getClassID(CLSID* pClsid) const;

This function is defined at the AcDbObject level. It is overridden for every other class that traces its derivation to AcDbObject, and is represented by a different COM object type. Thus, if you create a custom entity derived from AcDbEntity, and do not override getClassID(), this function returns the CLSID for AcadEntity. This means your custom entities will have at least base-level functionality, even if you do not provide COM support for them.

To obtain the CLSID for a given AcDbObject-derived class name, AutoCAD searches the registry for an entry that correlates the class name to its CLSID value.

The registry layout looks like this:

HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\
    ObjectDBX\
        R24.1\
            ActiveXCLSID\
                AcRxClassName\REG_SZ:
                    {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

In the example above, AcRxClassName represents the name of your AcDbObject-derived class (for instance, AcDbMyObject).