Reads data from a file, starting at the position indicated by the file pointer. After the read operation is complete, the file pointer is adjusted by the number of bytes actually read.
BOOLEAN ReadFile( HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped );
hFile
lpBuffer
nNumberOfBytesToRead
lpNumberOfBytesRead
lpOverlapped
CAUTION: Applications must not read from, write to, reallocate, or free the input buffer that a read operation is using until the read operation completes. Accessing the input buffer while a read operation uses the buffer may lead to corruption of the data read into that buffer.
When a read operation reaches the end of a file, ReadFile returns TRUE and sets *lpNumberOfBytesRead to zero. The following code sample shows a test for end-of-file.
// Attempt a synchronous read operation. bResult = ReadFile(hFile, &inBuffer, nBytesToRead, &nBytesRead, NULL) ; // Check for end of file. if (bResult && (nBytesRead == 0) ) { // you are at the end of the file. }
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 | intime/rt/include/winbase.h | windows.h | iwin32.lib |
Note
This function operates in the real-time portion of your application.
CreateFile, WriteFile, iwin32 API, iwin32 Overview