The difference between traditional DLL and COM DLL

前端 未结 8 1294
半阙折子戏
半阙折子戏 2021-01-30 03:23

I am currently studying COM. I found that COM DLL is kind of built upon the traditional DLL infrastructure. When we build COM DLLs, we still rely on the traditional DLL export m

相关标签:
8条回答
  • 2021-01-30 04:09

    I think by reading the first chapter of Essential COM by Don Box linked here, you'll have a very good idea of why we use COMs.

    To summarize: COM ensures compatibility at the binary level, no matter what language you used, or what version compiler you used. It is not about the "OOP" thing, you sure could expose C++ class from a DLL, but they are not "binary compatible."

    0 讨论(0)
  • 2021-01-30 04:10

    The key difference is that COM enables binary compatibility.

    If you add/remove functions and rebuild a traditional DLL then any client applications will probably fail when they try and use the DLL because they were built against the earlier version.

    COM introduced the concept of interfaces, which are immutable so should not be altered between builds, etc. Every COM object must implement the IUnknown interface which contains the QueryInterface method which is used to ask the object for pointers to other supported interfaces.

    The COM specification ensures that the IUnknown interface is always in the same place in the DLL so even if an object is revised to support more interfaces the QueryInterface method can still be called safely.

    0 讨论(0)
提交回复
热议问题