共用方式為


DECLARE_CLASSFACTORY

Declares CComClassFactory to be the class factory.

DECLARE_CLASSFACTORY( )

Remarks

CComCoClass uses this macro to declare the default class factory for your object.

Example

class ATL_NO_VTABLE CMyClass :
   public CComObjectRootEx<CComSingleThreadModel>,
   public CComCoClass<CMyClass, &CLSID_MyClass>,
   public IDispatchImpl<IMyClass, &IID_IMyClass, &LIBID_NVC_ATL_COMLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
   public IDispatchImpl<IMyDualInterface, &__uuidof(IMyDualInterface), &LIBID_NVC_ATL_COMLib, /* wMajor = */ 1, /* wMinor = */ 0>
{
public:
   DECLARE_CLASSFACTORY()

   // Remainder of class declaration omitted

Requirements

Header: atlcom.h

See Also

Concepts

Aggregation and Class Factory Macros

ATL Macros

DECLARE_CLASSFACTORY_EX

DECLARE_CLASSFACTORY2

DECLARE_CLASSFACTORY_AUTO_THREAD

DECLARE_CLASSFACTORY_SINGLETON