Chapter Twenty-Seven

Structured Storage

Like Automation and Uniform Data Transfer, structured storage is one of those COM features that you can use effectively by itself. Of course, it's also behind much of the ActiveX technology, particularly compound documents.

In this chapter, you'll learn to write and read compound files with the IStorage and IStream interfaces. The IStorage interface is used to create and manage structured storage objects. IStream is used to manipulate the data contained by the storage object. The IStorage and IStream interfaces, like all COM interfaces, are simply virtual function declarations. Compound files, on the other hand, are implemented by code in the Microsoft Windows OLE32 DLL. Compound files represent a Microsoft file I/O standard that you can think of as "a file system inside a file."

When you're familiar with IStorage and IStream, you'll move on to the IPersistStorage and IPersistStream interfaces. With the IPersistStorage and IPersistStream interfaces, you can program a class to save and load objects to and from a compound file. You say to an object, "Save yourself," and it knows how.