# ILayoutStorage

The ILayoutStorage interface enables an application to optimize the layout of its compound files for efficient downloading across a slow link. The goal is to enable a browser or other application to download data in the order in which it will actually be needed.

To optimize a compound file an application first saves it, then calls StgOpenLayoutDocfile to reopen the file using a special Compound Files implementation that exposes ILayoutStorage on its root storage. Once the storage is open, the application queries for a pointer to ILayoutStorage.

Using this pointer, the application can either provide explicit layout instructions or obtain them by monitoring the pattern of access to the compound file as it is loaded into memory.

- To monitor the order in which a compound file’s data is actually accessed, the application calls ILayoutStorage::BeginMonitor, after which the Compound Files implementation assumes that any operation performed on the storage or stream object is part of the desired access pattern. When the specified compound file is completely loaded, the application halts monitoring by calling ILayoutStorage::EndMonitor.

However the desired layout information is obtained, the application calls ILayoutStorage::ReLayoutDocfile to rewrite the compound file using either the explicit layout instructions or the monitored layout access patterns.

##### When to Implement

You do not need to implement this interface. A special implementation of Compound Files exposes ILayoutStorage on the root storage object.

##### When to Use

Use ILayoutStorage to optimize your application’s compound files. The interface is exposed in dflayout.dll, which is included with the Win32 SDK. If you are a web master, you can optimize compound files exposed in your web site by using the Docfile Layout Tool (dflayout.exe), which is also included with the Win32 SDK.

Methods in VTable Order

IUnknown Methods | Description
QueryInterface | Returns pointers to supported interfaces.
AddRef | Increments reference count.
Release | Decrements reference count.

ILayout Storage Method | Description
LayoutScript | Provides explicit layout instructions.
BeginMonitor | Monitors data access to a file.
EndMonitor | Ends monitoring of data access.
ReLayoutDocfile | Rewrites file using layout information.

See Also

ILayoutStorage