Component Object Model Examples?
#1 Members - Reputation: 203
Posted 15 April 2012 - 09:51 PM
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.
#2 Moderators - Reputation: 5018
Posted 16 April 2012 - 07:20 AM
#3 Members - Reputation: 2369
Posted 16 April 2012 - 07:22 AM
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.
#4 Members - Reputation: 203
Posted 16 April 2012 - 09:37 AM
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.
#6 Members - Reputation: 525
Posted 17 April 2012 - 03:50 PM
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
#7 Members - Reputation: 525
Posted 17 April 2012 - 05:17 PM
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.
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 ;)
#8 Members - Reputation: 203
Posted 17 April 2012 - 08:47 PM
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.
#9 Members - Reputation: 525
Posted 18 April 2012 - 05:43 PM
Pretty much, yeah.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. =)
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].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 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.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.
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.
#10 Members - Reputation: 203
Posted 18 April 2012 - 10:13 PM
Post them links when you get a chance!
Thanks, Ajm
#11 Members - Reputation: 125
Posted 26 April 2012 - 08:41 PM
http://www.codeproject.com/Articles/13601/COM-in-plain-C
Sorry for the late post and I hope it helps.
#12 Members - Reputation: 203
Posted 27 April 2012 - 04:11 PM






