Basic Services

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 mmioOpen8DMA.3 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 mmioOpen8DMA.3 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_RYKM1 function to close a file when you are finished reading or writing to it.

You can read and write files by using the mmioRead8DP67T and mmioWrite1MNLDQQ 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 mmioSeek205J4W5 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 MMIOINFO7F4X5_ structure, for example, you can open memory files, specify a custom I/O procedure, or supply a buffer for buffered I/O.