Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 4

Active Template Library

C++ Template Library for creating COM objects


Implementation support for
Component Housing
IUnknown
Class Factories
Aggregation Support
Dispatch Interfaces / Dual Interfaces
Connection points / Events
COM Enumerators
ActiveX controls
MSDN article: Creating an ATL Project

Mlardalen University - Graduate Course


Page 1, October 7, 2017
ATL Fundamentals

CComModule
CComObjectRoot<...>

CComCoClass<...>

IDispatchImpl<...>

CCustomClass

CComObject<...>

Mlardalen University - Graduate Course


Page 2, October 7, 2017
Some useful ATL Helper-Classes

CComBSTR
BSTR wrapper
CComVariant
Variant wrapper
CComPtr
Performs automatic reference counting
CComQIPtr
Same as CComPtr, plus automatic QueryInterface support
CComObjectLockT
Critical section handling, used when writing to member
variables in an MTA component.

Mlardalen University - Graduate Course


Page 3, October 7, 2017
ATL Helpers Code example

STDMETHODIMP CComObject::SomeMethod(IUnknown* pUnk)


{
CComQIPtr<ISomeInterface> spObj(pUnk);
CComBSTR bstrText;
spObj->GetText(&bstrText);
Automatic
ObjectLock lock(this); QueryInterface
m_bstrText = bstrText;
Thread Safe!
..
Automatic Automatic
.. Reference memory
} Counting! handling!

Mlardalen University - Graduate Course


Page 4, October 7, 2017

You might also like