Chapter 4. Objects in ATL

ATL’s fundamental support for COM can be split into two pieces: objects and servers. This chapter covers classes and concentrates on how IUnknown is implemented as related to threading and various COM identity issues, such as standalone versus aggregated objects. The next chapter focuses on how to expose classes from COM servers.

Implementing IUnknown

A COM object has one responsibility: to implement the methods of IUnknown. Those methods perform two services, lifetime management and runtime type discovery, as follows:

interface IUnknown {  // runtime type discovery  HRESULT QueryInterface([in] REFIID riid,                         [out, iid_is(riid)] void **ppv);  // lifetime management  ULONG AddRef();  ULONG Release ...

Get ATL Internals: Working with ATL 8, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.