82.7.1 Opening Memory Files

Like I/O buffers, memory files can use memory allocated by the application or by the file I/O manager. In addition, memory files can be either expandable or non-expandable. When the file I/O manager reaches the end of an expandable memory file, it expands the memory file by a predefined increment.

To open a memory file, use mmioOpen with the szFileName parameter set to NULL and the MMIO_READWRITE flag set in the dwOpenFlags parameter. Set the lpmmioinfo parameter to point to an MMIOINFO structure as follows:

Set the pIOProc field to NULL.

Set the fccIOProc field to FOURCC_MEM.

Set the pchBuffer field to point to the memory block. To request that the file I/O manager allocate the memory block, set pchBuffer to NULL.

Set the cchBuffer field to the initial size of the memory block.

Set the adwInfo[0] field to the minimum expansion size of the memory block. For a non-expandable memory file, set adwInfo[0] to NULL.

Set all other fields to zero.

82.7.1.1 Allocating Memory for Memory Files

There are no restrictions on allocating memory for use as a non-expandable memory file. You can use static memory or stack memory, or you can use locally allocated or globally allocated memory. For expandable memory files, you must use memory allocated using GlobalAlloc and locked using GlobalLock.