Collapse the table of content
Expand the table of content

IPersistStream interface

Enables the saving and loading of objects that use a simple serial stream for their storage needs.

When to implement

Implement the IPersistStream interface on objects that are to be saved to a simple stream. Some objects of this type are monikers and some OLE controls, although generally, controls use the IPersistStreamInit interface, which has the same methods as IPersistStream, with one added method, InitNew. The IMoniker interface is derived from the IPersistStream interface, so you must implement the IPersistStream interface if you are implementing a new moniker class.

When to use

Call the methods of IPersistStream from a container application to save or load objects that are contained in a simple stream. When used to save or load monikers, typical applications do not call the methods directly, but allow the default link handler to make the calls to save and load the monikers that identify the link source. These monikers are stored in a stream in the storage for the linked object. If you are writing a custom link handler for your class of objects, you would call the methods of IPersistStream to implement the link handler.


The IPersistStream interface inherits from IPersist. IPersistStream also has these types of members:


The IPersistStream interface has these methods.


Retrieves the size of the stream needed to save the object.


Determines whether an object has changed since it was last saved to its stream.


Initializes an object from the stream where it was saved previously.


Saves an object to the specified stream.



One way in which this interface is used is to support OLE moniker implementations. Each of the OLE-provided moniker interfaces provides an IPersistStream implementation through which the moniker saves or loads itself. An instance of the OLE generic composite moniker class calls the IPersistStream methods of its component monikers to load or save the components in the proper sequence in a single stream.

IPersistStream URL Moniker Implementation

The URL moniker implementation of IPersistStream is found on an URL moniker object, which supports IUnknown, IAsyncMoniker, and IMoniker. The IMoniker interface inherits its definition from IPersistStream and thus, the URL moniker also provides an implementation of IPersistStream as part of its implementation of IMoniker.

The IAsyncMoniker interface on an URL moniker is simply IUnknown (there are no additional methods); it is used to allow clients to determine if a moniker supports asynchronous binding. To get a pointer to the IMoniker interface on this object, call the CreateURLMonikerEx function. Then, to get a pointer to IPersistStream, call the QueryInterface method.

IPersistStream, in addition to inheriting its definition from IUnknown, also inherits the single method of IPersist, GetClassID.


Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]






IID_IPersistStream is defined as 00000109-0000-0000-C000-000000000046

See also




Community Additions

© 2015 Microsoft