1 / 12

Monikers

Monikers. Jim Fawcett CSE775 – Distributed Objects Spring 2007. References. About the only detailed reference is: Inside OLE, Second Edition, Kraig Brockschmidt , Microsoft Press, 1995 http://msdn2.microsoft.com/en-us/library/ms691261.aspx. Monikers.

msawyer
Download Presentation

Monikers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Monikers Jim Fawcett CSE775 – Distributed Objects Spring 2007

  2. References • About the only detailed reference is: • Inside OLE, Second Edition, KraigBrockschmidt, Microsoft Press, 1995 • http://msdn2.microsoft.com/en-us/library/ms691261.aspx

  3. Monikers • Here’s what Microsoft MSDN Library has to say about monikers: • Monikers are objects that implement the IMoniker interface and are generally implemented in DLLs as component objects. There are two ways of viewing the use of monikers: as a moniker client, a component that uses a moniker to get a pointer to another object; and as a moniker provider, a component that supplies monikers identifying its objects to moniker clients. • OLE uses monikers to connect to and activate objects, whether they are in the same machine or across a network. A very important use is for network connections. They are also used to identify, connect to, and run OLE compound document link objects. In this case, the link source acts as the moniker provider and the container holding the link object acts as the moniker client.

  4. What is a Moniker? • Monikers contain the logic necessary to find a currently running object by name (CLSID, URL). They can recreate and initialize an object instance in case there is no running instance. • Monikers provide persistent encapsulated names for: • Files • Database queries • Specific range of spreadsheet cells • Each moniker binds to one specific object

  5. So What is a Moniker? • A Moniker is a COM object that: • Implements the IMoniker interface • Provides persistent storage for descriptive text • Knows how to: • Instantiate and/or access its object • Cause some process to act on its object • Provides a “universal” interface so clients don’t need to know the details of what it does. • Very like the way the STL iterators shield clients from container details.

  6. So What is a Moniker? • In the Windows OS, a moniker is anything that implements a link, e.g.: • File associations (a specific extension is linked to an executable) • Short cuts • Bookmark to some place in a document • Link to a chart inserted in a word document

  7. What is a Moniker? • A moniker is a COM object that implements the IMoniker interface, which, in turn inherits the IPersistStream Interface: • Some of its IPersistStream methods are: • IPersist:GetClassID • IPersistStream:IsDirty, Load, Save, GetSizeMax • Monikers add the methods: • Binding:BindToObject, BindToStorage • Building and Reducing Composite Monikers:Reduce, ComposeWith, Enum, Inverse, RelativePathTo • Naming:GetDisplayName, ParseDisplayName • Other methods:IsEqual, Hash, IsRunning, GetTimeOfLastChange, IsSystemMoniker

  8. How are Monikers Used? • Create a COM object and initialize its state from persistant storage, as a single operaton. • Download a remote object’s server, register it, and instantiate the object, as happens with ActiveX objects on a webpage. • There are a number of System Monikers that do these kinds of operations. • System Monikers: • File monikers: reconstitute object from file • Class monikers: bind to an object’s class factory • Item monikers: bind to a part of a larger object, e.g., a range of cells in a spreadsheet.

  9. Class Moniker • Call CreateClassMoniker • Call BindMoniker • That returns pointer to class factory • Use that to create instance • Use the instance • Class monikers are placed in the per process activation table by RegisterClassObject, used by out-proc servers to support COM activation.

  10. File Moniker • Call CreateFileMoniker • Call BindToObject to bind file to an object • CLSID in file, or based on file extension • FileMoniker: • creates an instance of object • Calls QueryInterface asking for IPersistFile interface and uses its Load method to initialize the object • File moniker creates an initialized object

  11. Code Samples • In the code samples that follow, you will see applications of: • Class moniker • File moniker • Custom moniker

  12. End of Presentation

More Related