IPersistStorage  FG6L4R

The IPersistStorage interface defines methods that enable a container application to pass a storage object to one of its contained objects and to load and save the storage object. This interface supports the structured storage model, in which each contained object has its own storage that is nested within the container s storage.

The IPersistStorage contract inherits its definition from IPersistHYD1T0, so all implementations must also include the GetClassID method of IPersist.

When to Implement

Any object that can be embedded in a container must implement the IPersistStorage interface. This interface is one of the primary interfaces for a compound document object. Embeddable objects must also implement the IOleObject2WLX9VE and IDataObjectZHWNNR interfaces.

The OLE default handler for embedded objects provides an implementation of the IPersistStorage interface that is used when the object is in the loaded state. Similarly, the OLE default link handler provides an IPersistStorage implementation that manages storage for a linked object. These default handlers both interact with the OLE default cache implementation, which has its own IPersistStorage implementation.

If you are providing a custom embedding or link handler for your objects, the handler must include an implementation of IPersistStorage. You can delegate calls to the default handler so you can take advantage of the default cache implementation.

When to Use

When an OLE container creates a new object, loads an existing object from storage, or inserts a new object in a clipboard or a drag-and-drop operation, the container uses the IPersistStorage interface to initialize the object and put it in the loaded or running state. When an object is loaded or running, an OLE container calls other IPersistStorage methods to instruct the object to perform various save operations or to release its storage.

Typically, applications use helper functions such as OleLoadIJ4AB_ or OleCreate8VSC_N, rather than calling the IPersistStorage::Load5V6EFR or IPersistStorage::InitNewJMGO9D methods directly. Similarly, applications typically call the OleSave3ZML1K8 helper function rather than calling IPersistStorage::SaveS4I7H8 directly.

Methods in Vtable Order

IUnknown1NEM0LU Methods

Description

QueryInterface2Y54585

Returns pointers to supported interfaces.

AddRef1SHW0SS

Increments reference count.

ReleaseDUW01A

Decrements reference count.

 

IPersist Method

Description

GetClassID15MI_PE

Returns the class identifier (CLSID) for the object on which it is implemented.

 

IPersistStorage Methods

Description

IsDirtyOH.SHF

Indicates whether the object has changed since it was last saved to its current storage.

InitNewJMGO9D

Initializes a new storage object.

Load5V6EFR

Initializes an object from its existing storage.

SaveS4I7H8

Saves an object, and any nested objects that it contains, into the specified storage object. The object enters NoScribble mode.

SaveCompleted3F81ZN

Notifies the object that it can revert from NoScribble or HandsOff mode, in which in must not write to its storage object, to Normal mode in which it can.

HandsOffStorage1_6WALN

Instructs the object to release all storage objects that have been passed to it by its container and to enter HandsOffAfterSave or HandsOffFromNormal mode.

 

See Also

IDataObject, IOleObject, OleCreate, OleLoad, OleSave