Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[The feature associated with this page, Multimedia File I/O, is a legacy feature. It has been superseded by Source Reader. Source Reader has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Source Reader instead of Multimedia File I/O, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]
Using the basic I/O services is similar to using the run-time file I/O services of the C run-time library. Files must be opened before they can be read or written. After reading or writing, the file must be closed. You can also change the current read or write location within an open file.
Before you begin any I/O operations to a file, you must open the file by using the mmioOpen function. This function returns a file handle of type HMMIO. You can use this file handle to identify the open file when calling other file I/O functions.
Note
An HMMIO file handle is not a standard file handle. Do not use HMMIO file handles with Win32 or C run-time file I/O functions.
When you use mmioOpen to open a file, you use a flag to specify whether you are opening it for reading, writing, or both. You can also specify flags that enable you to create or delete a file. Use the mmioClose function to close a file when you are finished reading or writing to it.
You can read and write files by using the mmioRead and mmioWrite functions respectively. The next read or write operation occurs at the current file position or file pointer in a file. The current file position is advanced each time a file is read or written.
You can also change the current file position by using the mmioSeek function. You should ensure that you specify a valid location in a file. If you specify an invalid location, such as past the end of the file, mmioSeek may not return an error, but subsequent I/O operations could fail.
There are flags you can use with the mmioOpen function for operations beyond basic file I/O. By specifying an MMIOINFO structure, for example, you can open memory files, specify a custom I/O procedure, or supply a buffer for buffered I/O.