My Account Subscribe Help About
Sign In | Register FREE
Tuesday, April 14, 2026
UK faces biggest hit to growth from Iran war of major economies, IMF saysWhy and how is US blockading Iranian ports in Strait of Hormuz?Former Nato chief warns UK security 'in peril' as he accuses Starmer of 'corrosive complacency'We will name police and social workers unless action taken, lawyer for Southport families saysHouseholds could get free electricity for doing washing on sunny weekends'Welcome home': Watch joyful reunion as Orion capsule opened after splashdownWoman asked to leave bar after wheelchair deemed a 'safety risk'JD Vance defends backing 'great guy' Orbán's campaign after landslide defeatBurglars who used Rightmove to target homes and steal £1m of valuables jailedGreek police using masked migrants to forcibly push other migrants back across borderSingle-sex space guidance for organisations to be published after May electionsTracking the ships crossing the Strait of HormuzUS blockade of Iranian ports explained in two minutesOil prices continue to fall on hopes of new US-Iran peace talksLebanon seeks peace, but Hezbollah needs to be convinced firstHow a Primark trainer ended gang's £1m Rightmove burglary spreeWatch: What are Harry and Meghan doing in Australia?Hospital at centre of child HIV outbreak caught reusing syringes in undercover filmingAdam Peaty on his return to the pool, LA 2028 and Gordon Ramsay's wedding speechWhy one school has banned phones for some pupils - but not othersChris Mason: How Lammy and Vance's unlikely friendship is being utilisedOasis among record number of British acts entering Rock & Roll Hall of FameDoctor Who star Ncuti Gatwa to receive honorary doctoratePartner of US influencer who died in Zanzibar speaking to police as witnessFrench woman, 86, held by ICE after moving to US to reunite with long-lost loveChalamet thanked by Royal Ballet and Opera boss for boosting ticket salesGrand National horse trainer jailed for beating man with hockey stickBBC News appAmericanswers... on 5 Live! Donald Trump vs Pope Leo on IranThe "systemic failures" before the Southport attack
FDN » COM/DCOM » COM Fundamentals

COM Fundamentals

COM Fundamentals

COM (Component Object Model) is Microsoft's binary standard for inter-component communication. It enables language-independent, location-transparent object creation and method invocation.

Core Concepts

  • Interface: A contract — a set of related methods. Interfaces are immutable once published. Every COM object implements at least IUnknown (with QueryInterface, AddRef, Release).
  • CLSID: A 128-bit GUID that uniquely identifies a COM class. Registered in HKEY_CLASSES_ROOT\CLSID.
  • ProgID: A human-readable name for a COM class (e.g., ADODB.Connection). Mapped to a CLSID in the registry.
  • IDispatch: The interface for late-bound (Automation) access. VBScript and JScript use IDispatch exclusively.
  • Type Library: A binary file (.tlb) describing the interfaces, methods, and properties of a COM component. Used for early binding in VB6 and C++.

Object Creation

' Late binding (uses ProgID → CLSID lookup → IDispatch)
Set obj = CreateObject("Scripting.FileSystemObject")

' Early binding in VB6 (requires reference to type library)
Dim fso As New Scripting.FileSystemObject

COM Object Lifecycle

COM uses reference counting for memory management:

  1. CoCreateInstance creates the object. Reference count = 1.
  2. Each assignment calls AddRef. Count goes up.
  3. Setting a reference to Nothing calls Release. Count goes down.
  4. When count reaches 0, the object destroys itself.
Set obj = CreateObject("ADODB.Connection")  ' Ref count = 1
Set obj2 = obj                               ' Ref count = 2
Set obj = Nothing                            ' Ref count = 1
Set obj2 = Nothing                           ' Ref count = 0, object destroyed

Threading Models

ModelDescriptionUse Case
Single-ThreadedAll calls on the main threadLegacy components
Apartment (STA)Each thread has its own apartmentUI components, VB6 (default)
Free (MTA)Any thread can call any objectPerformance-critical C++ components
BothWorks in STA or MTAFlexible components
« Back to COM/DCOM « Back to FDN