IPersistStream  3K5UF8

The IPersistStream 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 IPersistHYD1T0 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 IPersistStorageQIWSID 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 IPersistStreamInitG9X0W7 interface, which has the same methods as IPersistStream, with one added method, IPersistStreamInit::InitNew_R21EX. The IMoniker18XK102 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 in Vtable Order

IUnknown1NEM0LU Methods

Description

QueryInterface2Y54585

Returns pointers to supported interfaces.

AddRef1SHW0SS

Increments the reference count.

ReleaseDUW01A

Decrements the reference count.

 

IPersist Method

Description

GetClassID15MI_PE

Returns the class identifier (CLSID) for the component object.

 

IPersistStream Methods

Description

IsDirty1O4LAB6

Checks the object for changes since it was last saved.

Load5_OA0S

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

Save5_V3OT

Saves an object into the specified stream and indicates whether the object should reset its dirty flag.

GetSizeMaxVMPIW9

Return the size in bytes of the stream needed to save the object.

 

See Also

IMoniker