Umesha MS
Umesha MS

Reputation: 2921

When and why do we need to use COM?

I want to know when and why to use COM?

Please let me know in which situation I need to use com instead of normal DLL.

Upvotes: 0

Views: 147

Answers (2)

reece
reece

Reputation: 8145

You use COM in various contexts, such as:

  1. interacting with the msxml3/4/6 XML API (consuming COM objects);

  2. embedding an Internet Explorer WebBrowser control (consuming COM objects);

  3. implementing Explorer Shell extensions such as context menus (writing and consuming COM objects);

  4. implementing drag and drop functionality (writing and consuming);

  5. using the Vista-based file open/close dialogs (consuming);

  6. using the Windows-based ribbon API (consuming).

Upvotes: 1

Eran
Eran

Reputation: 22010

First, it's worth mentioning that COM is quite an old technology. It significantly predates .NET, which sometimes provide the same functionality. However, comparing to a plain DLL, it has a few advantages, for example:

  1. It doesn't have a functional interface, but an OO one. You create objects rather than call exported functions.
  2. It supports system security settings, so you can manage access to a COM class via Windows security settings.
  3. It crosses process boundaries - the COM server can either be in the user's process, or in a separate one.
  4. It crosses machine boundaries, AKA DCOM.
  5. It crosses language boundaries. COM's protocol is binary, so every language that supports it, can use COM components regardless of the language those components have been created in.
  6. There are many languages that support COM, and in which you can easily create and use COM objects.

This is just the tip of the iceberg. Although dated, COM is widely used in Windows. Whether it's the right technology for you to use these days is a different matter - this really depends on your specific needs. But if you're a Windows programmer, it's definitively worth getting familiar with anyway. Even it you don't produce any COM product, you're very likely to consume one.

Upvotes: 6

Related Questions