Search notes:

IUnknown

Every COM object needs an IUnknown interface. It serves two purposes:

QueryInterface

TODO: It can be assumed that VBA implements typeOf(var) … is … using QueryInterface().

AddRef

AddRef() increases the reference counter of the object.

Release

Release() decreases the referece counter of the object.

VBA

In VBA, the reference counter of a (COM-)Object is released by setting the object to Nothing:
Dim obj As Object
…
Set obj = Nothing

c struct of vTable

#ifndef IUNKNOWN_VTABLE_INCLUDED
#define IUNKNOWN_VTABLE_INCLUDED

typedef  HRESULT (STDMETHODCALLTYPE  *funcPtr_IUnknown_QueryInterface)(void* self, REFIID riid, void **ppvObj);
typedef  ULONG   (STDMETHODCALLTYPE  *funcPtr_IUnknown_AddRef        )(void* self);
typedef  ULONG   (STDMETHODCALLTYPE  *funcPtr_IUnknown_Release       )(void* self);

//
// Create a macro for the IUnknown vTable because these
// function pointers are also needed in other COM vTables.
//
#define IUNKOWN_VTABLE                               \
  funcPtr_IUnknown_QueryInterface  QueryInterface;   \
  funcPtr_IUnknown_AddRef          AddRef;           \
  funcPtr_IUnknown_Release         Release;

typedef struct {
    IUNKOWN_VTABLE
}
IUnknown_vTable;

#endif
Github repository about-COM, path: /c/structs/IUnknown_vTable.h

See also

unknwn.h
VBA classes: reference counting
IDispatch
IUnknown in Visual Basic for Applications (VBA)
The .NET class System.__ComObject

Index