Why use COM?

Started by
3 comments, last by technomancer 17 years, 6 months ago
I have sort of a disposition towards COM at the moment and wanted to get some insight by those who really enjoy using it as to why use COM? Its an interface design, which is easy to do in C++ anyways so that shouldn’t be a compelling reason to use it. In order to use a COM object, you need to bind the COM engine to the current thread and use a complex ATL command (CoCreateInstance) to instantiate the COM object. Normal classes just need the constructor with a new command, which seams a heck of a lot simpler to me. So as far as I can tell the benefits of COM seam few as long as you have an SDK that will let you link into a DLL at runtime.
Advertisement
Drag and drop. See the tuts here: OLE Drag and Drop. COM is not without it's flaws. See What's Wrong with OLE? -- The Insider's story for a critique and a solution.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Writing code that will only run on Windows?
Want to provide an MS standard automation interface/script your app with VB?
Want to write once, use from many languages? (without using the CLR)
Want to reuse binaries on Windows without worrying about compiler compatibility?
Want to interface/automate Word/Excel/various third party apps?
Want to maximize the number of third party libraries you can leverage?

COM isn't meant for everything, but if you are writing non-game Win32 apps you will likely need to use it at some point. For example, it probably doesn't make sense for a game runtime, but it may be useful when working on game tools.
Isn't DirectX completely designed around COM?
Quote:Original post by Anonymous Poster
Isn't DirectX completely designed around COM?


Yep, all interfaces in DirectX are exposed through a COM object.

This topic is closed to new replies.

Advertisement