Compartilhar via


CComClassFactoryAutoThread Class

This class implements the IClassFactory interface, and allows objects to be created in multiple apartments.

Important

This class and its members cannot be used in applications that execute in the Windows Runtime.

class CComClassFactoryAutoThread : public IClassFactory,  
public CComObjectRootEx< CComGlobalsThreadModel >

Members

Public Methods

Name

Description

CComClassFactoryAutoThread::CreateInstance

Creates an object of the specified CLSID.

CComClassFactoryAutoThread::LockServer

Locks the class factory in memory.

Remarks

CComClassFactoryAutoThread is similar to CComClassFactory, but allows objects to be created in multiple apartments. To take advantage of this support, derive your EXE module from CComAutoThreadModule.

ATL objects normally acquire a class factory by deriving from CComCoClass. This class includes the macro DECLARE_CLASSFACTORY, which declares CComClassFactory as the default class factory. To use CComClassFactoryAutoThread, specify the DECLARE_CLASSFACTORY_AUTO_THREAD macro in your object's class definition. For example:

class ATL_NO_VTABLE CMyAutoClass :
   public CComObjectRootEx<CComMultiThreadModel>,
   public CComCoClass<CMyAutoClass, &CLSID_MyAutoClass>,
   public IMyAutoClass
{
public:
   DECLARE_CLASSFACTORY_AUTO_THREAD()

   // Remainder of class declaration omitted.

Inheritance Hierarchy

CComObjectRootBase

CComObjectRootEx

IClassFactory

CComClassFactoryAutoThread

Requirements

Header: atlcom.h

See Also

Reference

IClassFactory

CComClassFactory2 Class

CComClassFactorySingleton Class

CComObjectRootEx Class

CComGlobalsThreadModel

Other Resources

ATL Class Overview