Jump to content
  • Advertisement
Sign in to follow this  
ajm113

Component Object Model Examples?

This topic is 2303 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all, sorry to throw a dumb question out on the table. I've been doing some looking up on COM and looking at what all the business is with it. Funny enough even though I've been programming for such a long time this is the first time I've actually looked at what COM is and what it could do for me. I've looked at msdn, and a few websites talking about this, but I still kinda don't know 100% how I could use it.

From what I've seen or looked on here it only looks like a way of transferring data from one application to another, like ActiveX and Internet Explorer. To me it kinda seems like one of those things I have no use for, since I write basic programs and game engines sometimes using the stander libraries. I think I some how maybe missing the point.

I was wondering if someone could give me better examples what it's used for and why I should use it. It seems like the only useful thing I had it doing is creating a shortcut on my desktop, but I don't think that's even half of what it could do. I do want to expand my programming vocabulary and try to learn much about COM as possible.

Thanks, Ajm.

Share this post


Link to post
Share on other sites
Advertisement
I highly doubt you have a need for it, if all you do is basic games and engines. COM is a process designed to allow object creation across language boundaries, allowing access to those objects from anywhere, regardless of the language being used. While it is still used under the hood in some places, it's an aging technology and a complex beast, and if you find yourself posting forum threads to get people to tell you why and how you should be using it, that's a strong indicator that you have no need for it and shouldn't be using it.

Share this post


Link to post
Share on other sites
I developed Autocad applications using COM, 10 or more years ago. Autocad is absurdly proprietary and locked down, written in something. At the time I used Delphi.

I'd import the API, then work as if I had Autocad source. Similar to this:Autocad a = new Autocad();
Document d = a.newDocument();
d.drawLine([100, 100, 200, 200]);
Without having source or anything else, just exposed COM type libraries.

As Autocad went through versions, the COM API remained the same. So my applications written 10 years ago in Delphi still work today with 10 later versions of Acad.

And since COM completely abstracts the running environment, Acad can use my applications, without Autodesk having to add support for it.


But between WinRT, .Net and managed languages, it's a legacy technology that involves a lot of pain and suffering, so unless you have a well-paying job lined up, it's best left forgotten.

Share this post


Link to post
Share on other sites
Wow, thanks for your information guys! Thats pretty interesting it could be used like that. smile.png

I've been trying to look at what libraries are mostly used in the industry besides Win32 Window Functions, and I've seen COM listed once and a great while, but I'm mostly looking at libraries or maybe anything I don't know that a good 30% or more of compaies use for their software. I pretty much used the most used libraries with Win32 such as basics of Networking, File handling, GUIs, with OpenGL of course, but is there anything else out there that would be a good to learn?

I hunger for more in a sense.

Share this post


Link to post
Share on other sites
The whole DirectX suite is COM.

You create your Direct3D object using its interface. Similarly the DirectX audio and input systems, if you are using them, are done through COM.

Share this post


Link to post
Share on other sites
COM is actually pretty nifty, You can (assuming we are running Windows here) have objects created in almost any language, and use them from not only almost any other language, but also from another process, or even another computer on the network. (This can, for example, be used to solve some tricky problems where some parts are 32 bit code and others are 64 bit, but I digress...)

It's a shame that a whole generation didn't bother to learn it. I also don't understand where the notion comes from that it's obsolete? Nothing that has come out of Microsoft since quite offers a replacement for what it does.

The problem with it is that is kind of complicated to use from certain languages (C++ comes to mind, in .NET on the other hand it's braindead easy to both use and create COM components). It might also be tricky to configure correctly.

Microsoft seems to solve some of the issues, to make WinRT easier to use from C++. (Yes, WinRT is basically a COM API, so Microsoft is using "obsolete" tech to write their latest API rolleyes.gif).

Share this post


Link to post
Share on other sites
Sorry for replying twice in a row, but I felt a sudden urge to respond more directly to the OP's points. Hope that's OK.


Hello all, sorry to throw a dumb question out on the table. I've been doing some looking up on COM and looking at what all the business is with it. Funny enough even though I've been programming for such a long time this is the first time I've actually looked at what COM is and what it could do for me. I've looked at msdn, and a few websites talking about this, but I still kinda don't know 100% how I could use it.


It's kind of funny, but until you have an idea of what it is, it can be difficult to get an idea of what it is, and why it is ;)


From what I've seen or looked on here it only looks like a way of transferring data from one application to another, like ActiveX and Internet Explorer. To me it kinda seems like one of those things I have no use for, since I write basic programs and game engines sometimes using the stander libraries. I think I some how maybe missing the point.

I was wondering if someone could give me better examples what it's used for and why I should use it. It seems like the only useful thing I had it doing is creating a shortcut on my desktop, but I don't think that's even half of what it could do. I do want to expand my programming vocabulary and try to learn much about COM as possible.

Thanks, Ajm.
[/quote]

COM ha been known under so many names already, it's not even funny: OLE, Network OLE, COM, DCOM, COM+, ActiveX (and all of the names I forgot) are basically just what is known as COM in one way or another.

The first thing you need to know is that COM is not a library, it's a method of writing and consuming libraries.

Do you have Visual Studio? To get a quick taste of using COM libraries, create a new empty C# project. Right click "references" in the solution explorer. In the dialog that pops up, select COM. You now see a list of all COM libraries that you have intalled. Select the one you want to use, and presto, you now have access to all the objects in that library.

To make a COM component yourself in C# that others can use, googling "ComVisible" should take you a long way.

What can this be used for in games? Well, extensions of course.

Want to make a plugin system? Define a COM interface that the plugin must implement. As a bonus, you can even make the plugin run in another addres space, so it doesn't take your game with you when it crashes.

You can also have parts of your game exposed as a COM API that can be accessed from the outside, or perhaps from inside the plugins that your COM plugin system loads ;)

Share this post


Link to post
Share on other sites
Wow, thats pretty cool, so then it's kinda just like a plugin or a tab in Google Chrome, if a page or a plugin crashes, it wont crash Chrome it's self. =)

Hey I could actually maybe use this technique, for future projects then, if it may means less frustration in the future for my users I don't see why not to learn it then.

I actually use C++ as my main language so I may play around with it more in C++, but I don't see why not to use C# just for fun. Just a quick question, if say my main program crashes I guest the plugins would go down as well. I was thinking it could be used to detect if a program crashes.

Share this post


Link to post
Share on other sites

Wow, thats pretty cool, so then it's kinda just like a plugin or a tab in Google Chrome, if a page or a plugin crashes, it wont crash Chrome it's self. =)

Pretty much, yeah.

Hey I could actually maybe use this technique, for future projects then, if it may means less frustration in the future for my users I don't see why not to learn it then.
[/quote]
My opinion is that everyone who is a windows programmer should learn at least something about COM, otherwise they are missing out on a great tool, and also a big part of the Windows software ecosystem. Unfortunately, it isn't easy to find a great overview that explains it all in an understandable manner, which leads them to just ignore it and say that it's been replaced by [insert non-related tech here].

I actually use C++ as my main language so I may play around with it more in C++, but I don't see why not to use C# just for fun.
[/quote]
I will (probably tomorrow) try to gather some links to examples of COM usage. It's probably easier to begin with C# examples, as it is much clearer what is being accomplished without all the confusing stuff you need to do in C++, but I will attempt to find good C++ examples also. :)

Just a quick question, if say my main program crashes I guest the plugins would go down as well. I was thinking it could be used to detect if a program crashes.
[/quote]

Well, I guess it's possible. If you are using an object from an outproc server (which could be your main application), the client would receive a RPC_E_SERVERFAULT if the main application crashes. But I would not use it in that way.

Share this post


Link to post
Share on other sites
Really, that would be cool! I would like to see some of those links! I think knowing COM maybe a really good asset to learn encase if a project needs to get more complex. =)

Post them links when you get a chance!

Thanks, Ajm

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!