Use the mmioCreateChunk function to create a new chunk by writing a chunk header at the current position in an open file and then "descending" into the chunk. (See Descending into a Chunk for further information.) You must specify a pointer to a MMCKINFO structure containing information about the new chunk. You also need to determine which chunk type to create by specifying MMIO_CREATERIFF or MMIO_CREATELIST. The return value is 0 if the chunk is successfully created; otherwise, the return value specifies an error code.
The following code fragment illustrates how to create a new chunk with a chunk ID of RIFF and the form type of WAVE.
HMMIO hmmio; MMCKINFO mmckinfo; . . . mmckinfo.fccType = mmioFOURCC('W', 'A', 'V', 'E'); mmioCreateChunk(hmmio, mmckinfo, MMIO_CREATERIFF);
If you are creating a RIFF or LIST chunk, you must specify the form type in the fccType field of the MMCKINFO structure. In the previous example, the form type is WAVE.
If you know the size of the data field in the new chunk, set the ckSize field in the MMCKINFO structure when you create the chunk. This value is written to the ckSize field in the new chunk. If this value is not correct when you call mmioAscend to mark the end of the chunk, it is automatically rewritten to reflect the correct size of the data field.
After you create a new chunk using mmioCreateChunk, the file position is set to the data field of the chunk (8 bytes from the beginning of the chunk). If the chunk is a RIFF or LIST chunk, the file position is set to the location following the form type or list type (12 bytes from the beginning of the chunk). The ckSize field is assumed to be a "proposed chunk size" if it turns out to be correct (if you write that much data into the chunk before calling mmioAscend to end the chunk, the mmioAscend will not have to seek back and correct the chunk header.)