Reading and Writing

When a file is first opened, Windows places a file pointer at the beginning of the file. The file pointer marks the current position in the file where the next read or write will take place. As each byte is read or written, Windows advances the file pointer. An application can also move the file pointer position with the SetFilePointer function.

An application performs the actual read and write operations with the ReadFile and WriteFile functions. These functions read and write a specified number of bytes at the location of the file pointer without formatting the data. Listing 17.2 shows a code segment where consecutive calls to WriteFile build a string in a file and ReadFile reads the string from the file.

Code Listing 17.2. ...

Get Microsoft Windows 2000 API SuperBible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.