|
For any given
platform COM defines a standard way to lay out virtual function tables in
memory, and a standard way to call functions through the vtables. Thus, any
language that can call functions via pointers all can be used to write
components that can interoperate with other components written to the same
binary standard. The double indirection ( tha is the client holds a pointer
to a pointer to a vtable) allows for vtable sharing among multiple instances
of the same object class. How is this standard implemented?By the
use of interfaces.For an application a component is just a black box with all
the functionality strongly encapsulated. The only way to access a COM object
is through an interface. Its a set of functions that you can call to get the
object to do something. An interface is just a related group of functions and
is the binary standard through which clients and component objects
communicate. Every interface has its own interface identifier, a globally
unique ID. COM interfaces are never versioned, which means that version
conflicts between new and old components are avoided. A new version of an
interface, created by adding more functions or changing semantics, is an
entirely new interface and is assigned a new unique identifier. By using your
machine's unique network card ID, the current time, and other data, these
identifiers, called GUIDs (globally unique identifiers) are created by a
program called GUIDGEN.EXE. GUIDs are stored in 16-byte (128 bit) structures,
giving 2128 possible GUIDsThese GUIDs are UUIDs (universally
unique IDs) as defined by the Open Software Foundation's Distributed
Computing Environment.
The Component Object Library is a system component that provides the
mechanics of COM. The Component Object Library provides the ability to calls across processes; it also
encapsulates all the "legwork" associated with launching components
and establishing connections between components. Typically when an
application creates a component object, it passes the CLSID of that component
object class to the Component Object Library. The Component Object Library
uses that CLSID to look up the associated server code in the registration
database. The Component Object Library is implemented in COMPOBJ.DLL for
Windows and OLE32.DLL for Windows NT and Windows 95..
|