共用方式為


Object Map Macros

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Object Map Macros.

These macros define object maps and entries.

DECLARE_OBJECT_DESCRIPTION Allows you to specify a class object's text description, which will be entered into the object map.
OBJECT_ENTRY_AUTO Enters an ATL object into the object map, updates the registry, and creates an instance of the object.
OBJECT_ENTRY_NON_CREATEABLE_EX_AUTO Allows you to specify that the object should be registered and initialized, but it should not be externally creatable via CoCreateInstance.

DECLARE_OBJECT_DESCRIPTION

Allows you to specify a text description for your class object.

DECLARE_OBJECT_DESCRIPTION(Â
    x Â)

Parameters

x
[in] The class object's description.

Remarks

ATL enters this description into the object map through the OBJECT_ENTRY macro.

DECLARE_OBJECT_DESCRIPTION implements a GetObjectDescription function, which you can use to override the CComCoClass::GetObjectDescription method.

The GetObjectDescription function is called by IComponentRegistrar::GetComponents. IComponentRegistrar is an Automation interface that allows you to register and unregister individual components in a DLL. When you create a Component Registrar object with the ATL Project Wizard, the wizard will automatically implement the IComponentRegistrar interface. IComponentRegistrar is typically used by Microsoft Transaction Server.

For more information about the ATL Project Wizard, see the article Creating an ATL Project.

Example

class ATL_NO_VTABLE CMyDescribedClass :
   public CComObjectRoot,
   public CComCoClass<CMyDescribedClass, &CLSID_MyDescribedClass>
{
public:
   CMyDescribedClass()
   {
   }

   // Override CComCoClass::GetObjectDescription
   DECLARE_OBJECT_DESCRIPTION("My Described Object 1.0")
};

OBJECT_ENTRY_AUTO

Enters an ATL object into the object map, updates the registry, and creates an instance of the object.

OBJECT_ENTRY_AUTO(Â
    clsid, Â
    class Â)

Parameters

clsid
[in] The CLSID of a COM class implemented by the C++ class named class.

class
[in] The name of the C++ class implementing the COM class represented by clsid.

Remarks

Object entry macros are placed at global scope in the project to provide support for the registration, initialization, and creation of a class.

OBJECT_ENTRY_AUTO enters the function pointers of the creator class and class-factory creator class CreateInstance functions for this object into the auto-generated ATL object map. When CAtlComModule::RegisterServer is called, it updates the system registry for each object in the object map.

The table below describes how the information added to the object map is obtained from the class given as the second parameter to this macro.

Information for Obtained from
COM registration Registry Macros
Class factory creation Class Factory Macros
Instance creation Aggregation Macros
Component category registration Category Macros
Class-level initialization and cleanup ObjectMain

OBJECT_ENTRY_NON_CREATEABLE_EX_AUTO

Allows you to specify that the object should be registered and initialized, but it should not be externally creatable via CoCreateInstance.

OBJECT_ENTRY_NON_CREATEABLE_EX_AUTO(Â
    clsid, Â
    class Â)

Parameters

clsid
[in] The CLSID of a COM class implemented by the C++ class named class.

class
[in] The name of the C++ class implementing the COM class represented by clsid.

Remarks

Object entry macros are placed at global scope in the project to provide support for the registration, initialization, and creation of a class.

OBJECT_ENTRY_NON_CREATEABLE_EX_AUTO allows you to specify that an object should be registered and initialized (see OBJECT_ENTRY_AUTO for more information), but it should not be creatable via CoCreateInstance.

See Also

Macros