Structured storage is a file system within a file. COM uses it to efficiently store multiple types of objects in one document. COM defines structured storage as a collection of two types of COM objects, storage and stream. The former behaves as a directory and the latter as a file. A storage object must implement the IStorage interface and a stream object must implement the IStream interface. Just as a directory in a file system can contain subdirectories and files, a storage object can contain other storage objects and stream objects. A storage object keeps track of the locations and sizes of the contained storage and stream objects. A stream object stores data as a consecutive sequence of bytes.
Structured storage helps to reduce the performance penalties and overhead for storing separate objects in a flat file. Other benefits include incremental access and multiple uses of data in a transacted process, as well as providing facilities for saving files in low-memory situations. Windows CE provides a default implementation, currently for the H/PC platform, of the interfaces, functions, and enumeration required for structured storage services. This default implementation includes the following:
These interfaces provide methods for opening storage, committing and reverting changes, copying and moving elements, and reading and writing streams.
These interfaces provide methods for reading data formats of individual objects and are capable of executing persistent storage.
This interface provides methods for writing files to specific types of physical storage media, such as hard disks or tape drives. Objects implementing this interface are known as LockBytes objects. Windows CE does not provide any LockBytes objects when implementing default structured storage.
These functions allow clients to create a new compound file or to open an existing one on a default or custom LockBytes object.
The flags listed in STGM permit clients to specify the access modes for regulating access to compound files.