Creating the IUnknown Interface
The IUnknown interface defines three member functions that must be implemented for each object that is exposed. The prototypes for these functions reside in the header file, Ole2.h.
QueryInterface — Identifies which OLE interfaces the object supports.
AddRef — Increments a member variable that tracks the number of references to the object.
Release — Decrements the member variable that tracks the instances of the object. If an object has zero references, Release frees the object.
These functions provide the fundamental interface through which OLE can access objects. The COM Programmer's Reference describes in detail how to implement the functions.