The IStorage interface supports the creation and management of structured storage objects. These storage objects provide hierarchical storage of information within a single file similar to a file system within a file. Storage objects are like the directories in a file system. They provide the structure in a structured storage object. They can contain other storage objects which can be nested indefinitely, or stream objects. Stream objects are like the files within a file system. They contain the actual data content in a storage object.

The IStorage interface provides methods for creating and managing the root storage object, child storage objects, and stream objects. These methods can create, open, enumerate, move, copy, rename, or delete the elements in the storage object.

An application must release its IStorage pointers when it is done with the storage object to deallocate memory used. The IStorage interface provides a IUnknown::Release method. There are also methods for changing the date and time of an element.

Storage objects can be opened in direct or transacted mode. In direct mode, changes are immediately reflected in the element that changed. In transacted mode, changes are not reflected in the element until explicitly committed. This feature allows you to revert to a previous version without committing the changes. The IStorage interface provides methods for committing changes and reverting to previous versions of the storage object.

Storage objects and their elements have a set of access flags that control how the elements can be used. For example, a stream can be opened in read only mode or read/write mode. See the STGM enumeration values for more information on these flags. Storage objects and their elements also have a set of statistics defined by the STATSTG structure.

When to Implement

OLE provides an implementation of the IStorage interface in compound files. The compound file implementation supports transacted access. OLE provides a set of helper APIs for using the compound file implementation of storage objects.

Container or object applications can implement their own storage objects instead of using the OLE-provided implementation.

When to Use

Container applications use storage objects for compound files. For example, a word processing document could contain a chart. The chart would be provided its own storage object within the root storage object of the containing application while document pages are stored in a separate storage object in the same root storage object.

Since storage object pointers can be marshaled to other processes, applications can share the data in storage objects without having to use global memory. For the OLE-provided implementation of compound files, the custom marshaling facilities in OLE create a remote version of the original object in the new process when the two processes have shared memory access. Thus, the remote version does not need to communicate with the original process to carry out its functions.

While the IStorage and IStream interfaces are used to deal with the storage object and its elements, the IPersistStorage interface actually serializes the storage object and its elements to a disk file.

Methods VTable Order

IUnknown Methods
Returns pointers to supported interfaces.
Increments the reference count.
Decrements the reference count.

IStorage Methods
Creates and opens a stream object with the specified name contained in this storage object.
Opens an existing stream object within this storage object using the specified access permissions in grfMode.
Creates and opens a new storage object within this storage object.
Opens an existing storage object with the specified name according to the specified access mode.
Copies the entire contents of this open storage object into another storage object. The layout of the destination storage object may differ.
Copies or moves a substorage or stream from this storage object to another storage object.
Reflects changes for a transacted storage object to the parent level.
Discards all changes that have been made to to the storage object since the last commit operation.
Returns an enumerator object that can be used to enumerate the storage and stream objects contained within this storage object.
Removes the specified element from this storage object.
Renames the specified element in this storage object.
Sets the modification, access, and creation times of the indicated storage element, if supported by the underlying file system.
Assigns the specified CLSID to this storage object.
Stores up to 32 bits of state information in this storage object.
Returns the STATSTG structure for this open storage object.

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database