Windows COM API Reference

Explore the Component Object Model (COM), a powerful binary interface standard that allows applications and components to interact, regardless of the language they were written in or the location they reside. This section provides comprehensive documentation on COM interfaces, methods, and concepts essential for Windows development.

Core COM Concepts

Interface: A contract that defines a set of related functions (methods) that a COM object supports. Objects implement interfaces to expose their functionality.
Class: A concrete implementation of one or more COM interfaces. A class provides the actual code for the methods defined in its interfaces.
GUID (Globally Unique Identifier): A unique 128-bit value used to identify COM interfaces and classes. Also known as IIDs (Interface Identifiers) and CLSIDs (Class Identifiers).
Aggregation & Containment: Techniques for object composition, allowing one COM object to contain or utilize the functionality of another COM object.

Key COM Interfaces

Essential COM Functions & Structures

Interface: IUnknown

The base interface for all COM objects. It provides reference counting and object identity management.

Methods:

QueryInterface

HRESULT QueryInterface(REFIID riid, void** ppvObject);

Retrieves a pointer to a different interface on the same COM object.

AddRef

ULONG AddRef();

Increments the reference count for the COM object.

Release

ULONG Release();

Decrements the reference count for the COM object. When the count reaches zero, the object is destroyed.

Interface: IClassFactory

Provides methods for creating instances of a COM class.

Methods:

CreateInstance

HRESULT CreateInstance(IUnknown* pUnkOuter, REFIID riid, void** ppvObject);

Creates an uninitialized object.

Interface: IDispatch

Enables an object to expose its properties and methods to late-binding languages such as VBA, VBScript, and JScript.

Methods:

Function: CoCreateInstance

HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID* ppv);

Creates a single, uninitialized object of the specified type.

Function: CoInitializeEx

HRESULT CoInitializeEx(LPVOID pvReserved, DWORD dwCoInit);

Initializes the COM library on the current thread.

Function: CoUninitialize

VOID CoUninitialize();

Closes the COM library on the current thread.

Structure: GUID


typedef struct _GUID {
    unsigned long  Data1;
    unsigned short Data2;
    unsigned short Data3;
    unsigned char  Data4[ 8 ];
} GUID;
            

Represents a globally unique identifier.

Further Reading