DCOM Explained
by Rosemary Rock-Evans Digital Press ISBN: 1555582168 Pub Date: 09/01/98 |
Previous | Table of Contents | Next |
The IUnknown Interface is a fundamental interface containing basic operations common to all classes and interfaces. IUnknown has three methodsQueryInterface, AddRef, and Release.
QueryInterface is used to find out what interfaces a class supports. The client first uses an Interface Name to start the process. Clients will have been given the name of the interface they should use, as the starting point of the invocation process. COM then returns the pointer to this interface.
The client can then use this pointer and the QueryInterface method to find out what other interfaces exist on the same class. As Microsoft puts it: The GUID of the interface is input and what returns is an interface on itself through an accompanying output parameter typed as a generic void! This facility can be used both to find out the other interfaces and also to see if an interface is still valid.
The AddRef and Release methods are used to keep track of how many occurrences/instances of an object there are on that host. We will look at the mechanics of how this works in the section on triggers, but it is important to understand that the count of occurrences is done by the classes themselves, not COM, using these method calls. In effect, the class has to be written so that it both keeps a count of how many instances there are and also makes sure the class is released once it is no longer used.
It is worth mentioning that if aggregation or containment is used, the developer needs to implement one set of IUnknown functions for all the interfaces, not just the main classs interface.
Monikers are alias names that can be used to provide alternative names for files. In general, file names dont provide any information about what is in the fileit could be an executable, paragraph in a document, range of spreadsheet cells, range of data, or even a query on a database.
A Moniker is a class/component which encapsulates what the file is. In effect, the name itself becomes a component accessed via the IMoniker interface. Clients always work with names through this interface, not the names themselves, and the Moniker class defines operations which are used to locate components or perform some action on components of that type. Each Moniker class has a different CLSID and its own semantics as to what sort of class and operations it can refer to.
Microsoft has defined its own types of monikerfiles, items, and so on, but clearly new ones can be added. Generic moniker operations include the ability to bind to an object to which it points, binding to the classs storage and reductionrewriting itself into another equivalent moniker.
Previous | Table of Contents | Next |