What is COM. I always see it, and I'm learning VB now. I can't seem to get a straight answer on COM.
Printable View
What is COM. I always see it, and I'm learning VB now. I can't seem to get a straight answer on COM.
From MSDN:
Component Object Model (COM)
The OLE object-oriented programming model that defines how
objects interact within a single process or between processes. In
COM, clients have access to an object through interfaces
implemented on the object.
COM Overview
The Component Object Model (COM) is a binary standard that
defines how objects are created and destroyed and, most
importantly, how they interact with each other. As long as
applications follow the COM standard, different applications from
different sources can communicate with each other across
process boundaries. People use COM to make communication
with other applications easy.
Because COM is a binary standard, it is language independent.
You do not have to use C++ to implement COM. You can use any
language that supports tables of function pointers.
A COM interface is a collection of logically related methods that
express a single functionality. For example, the IAsyncReader
interface enables reading of MEDIATYPE_Stream data. All COM
interfaces derive from IUnknown, and all are named by a globally
unique interface identifier (IID).
A COM class is an implementation of one or more COM interfaces,
and a COM object is an instance of a COM class. A Microsoft®
DirectShow™ filter, for example, is a COM object. Each object has
a globally unique class identifier (CLSID).
Kinda formal explanation, but just search the forums for some
examples that may give you a better explanation.
HTH
Thanks. Um, basicly COM helps .exe files communicate with each other. Can COM pass information from application to application? How would I develop COM functions, what is the environment and how would I find the syntax?
I haven't really used COM outside of MS Office, but this is the
same. If you add a reference to MS Access in a new vb standard
project, you can use the Object Browser to see all the objects,
properties, and events available from Access. You can add
another reference to MS Excel and see its Objects the same way.
Then you can create an instance of Access and Excel and
automate them through VB. You would be using Components of
Access and Components of Excel. Basically COM is Components
that can be reused in other applications by referencing their
object libraries. I may not have the entire concept, but this is the
basics. I suggest searching for examples and tutorials to help you
more.
so, COM is mainly used to communicate between MS Office applications like Word and Excel? What environment is COM developed in?
Not at all. COM is used in multi-tiered apps. You write a dll for one
program, and say, you need to use some function in another app,
then you could create an instance of the object and execute the
function. I am probably not explaining everything correctly, but I
am still learning COM or distributed applications.
COM objects could be written in C++ or VB I believe.
COM exists as a Windows Communication Layer used as a Marshaling medium used for Inter-Application Communications.Quote:
Originally posted by SEGACIOUS
so, COM is mainly used to communicate between MS Office applications like Word and Excel? What environment is COM developed in?
IE.. App1 -> Windows -> App2 -> Windows -> App1
P.S. Com, OLE and, ActiveX can be used interchangeably. Microsoft has changed all those definitions over the years and they have all at one time meant the same thing.
AFAIK no other OS supports COM, although some could argue SOAP is a version of COM... or was that CORBA...
This article (pushing COM development) has a good description of multi-tier (or is it multi-layer ) development (It's a good read).
http://msdn.microsoft.com/library/de...complus4vb.asp
10 years old, but talks about OLE 2.0 which is COM:
http://msdn.microsoft.com/library/de...msdn_ole2d.asp
Thanks Dave for a much better explaination.
:thumb:
Other points of interest (for the truly bored) are IDL (Interface Description Language) and ATL (Active Template Library), which are the foundations which COM is built on.
The best description for com is :
An programming indepent system for developing reusable components
COM is an interface that can communicate with almost any programming language.
The main advantage is that i could write an component in C++ and (if i do it by the rules) VB can use that component.
The only prob is that C++ have way more flexiblity to bend the rules of com than VB so lot's of components work very poor with other languages.
Even Microsoft didn't always obeys it's own rules.
ATL is an library which can be used to build COM, but COM componets can also be build using MFCQuote:
Originally posted by Dave Sell
Other points of interest (for the truly bored) are IDL (Interface Description Language) and ATL (Active Template Library), which are the foundations which COM is built on.
isnt ATL built on top of MFC?
Nope, ATL is an complete differnt,Quote:
Originally posted by Dave Sell
isnt ATL built on top of MFC?
they can be used in an single component, but they can also be used indepently.
Actually ATL was created to get rid of the overhead of MFC, it's used to create lightweight and fast code, as MFC is used to create slower bulkier code.
Rule of thumb :
MFC => Mainly GUI (clients), nowadays actually VB(.net)
ATL => Mainly fast (COM)DLL's without an GUI interface.
ATL+MFC => (com)DLL's with an GUI
MFC=> (com)DLL's just as fast as VB activeX, so no need for it to do it in C++ then