cwinapidllcombinary-compatibility

Why is the Windows API not exposed through COM?


I understand that the basic problem COM solves is the issue with binary compatibility of software libraries. That is why a lot of (low level) windows services are exposed through the COM system. But why is the Windows API itself not exposed through COM? It seems that the DLLs implementing the Windows API have somehow managed to stay binary compatible with all sorts of compilers and as such the Windows API has no need to be exposed through COM.


Solution

  • The basic Windows ABI is stable and is as compatible as COM. If a compiler supports COM it supports the basic API as well, on x86 they are both stdcall functions.

    Exposing everything as a COM interface does not make sense for many reasons.

    The only positive would be that high-level scripting code could call these functions but in practice most COM interfaces are not dual and do not support IDispatch and therefore cannot be scripted. The exceptions are Internet Explorer, Office and some of the shell stuff (Shell.Application).

    For things that are extensible or runs out-of-process, COM makes a lot of sense. It is easy to define the interfaces and IPC is taken care of for you.

    With the introduction of UWP/WinRT you are somewhat getting your wish...