Next post regarding COM and ATL


Handles COM infrastructure, implements all common stuff.

ATL is set of headers, is VS type of project.

Provides a class “CComModule” and global instance “_Module”, it initialized/uninitialized within DllMain (attach/detach).

It provides set of operations – register/unregister COM dll, creating class object.

BEGIN_OBJECT_MAP(ObjectMap)/END_OBJECT_MAP() – embraces all coclasses defined within module by OBJECT_ENTRY(<coclass name>) macro.

Registration for COM servers: for inrpoc – “regsvr32” utility, for local servers – “register/unregister” parameter for WinMain.

CoClass template

class ATL_NO_VTABLE CCoHexagon :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CCoHexagon, &CLSID_CoHexagon>,
public IDraw
public: CCoHexagon() { }
// IDraw
STDMETHOD(<method name>)();

CComObjectRootEx<> provides IUnknown implementation

BEGIN_COM_MAP(<coclass name>)/END_COM_MAP() embraces interfaces declaration by COM_INTERFACE_ENTRY(<interface name>)

CComCoClass<CCoHexagon, &CLSID_CoHexagon> – defines coclass factory, handles aggregation

rgs-files – registry scripting

Properties – for VB, for C++ just a syntax sugar: methods get_<prop name>, set_<prop name>

IDL definition:[propget], function parameter specification: [out, retval]

COM string: CComBSTR – wrapper over raw BSTR

Text conversion macroses: converts between C (const C++ string), A (ANSI char*), BSTR, W, T, OLE strings.

ATLTRACE – trace macro for ATL debugging.


About DmitryKrinitsyn
Software developer

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: