IPersistStream (Compact 2013)
3/26/2014
This interface provides methods for saving and loading objects that use a simple serial stream for their storage needs. The IPersistStream interface inherits its definition from the IPersist interface, and so the includes the GetClassID method of IPersist.
One way in which it 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.
OLE containers with embedded and linked component objects do not use this interface; they use the IPersistStorage interface instead.
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, IPersistStreamInit::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 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.
Methods
The following table shows the methods for this interface in the order that the compiler calls the methods. Like all COM interfaces, this interface inherits the methods for the IUnknown interface.
IUnknown method |
Description |
---|---|
Returns pointers to supported interfaces. |
|
Increments reference count. |
|
Decrements reference count. |
IPersist Method |
Description |
---|---|
Returns the class identifier (CLSID) for the component object. |
IPersistStream method |
Description |
---|---|
Checks the object for changes since it was last saved. |
|
Initializes an object from the stream where it was previously saved. |
|
Saves an object into the specified stream and indicates whether the object should reset its dirty flag. |
|
Return the size in bytes of the stream needed to save the object. |
Remarks
To determine whether the platform supports this interface, see Determining Supported COM APIs.
Requirements
Header |
objidl.h, |
Library |
ole32.lib, |
See Also
Reference
COM Interfaces
IMoniker
IPersist
IPersistStorage
IPersistStreamInit
IPersist::GetClassID
IPersistStreamInit::InitNew