Reading from a File

Use the ReadFile function to read data from a file. ReadFile uses the returned handle from CreateFile in the hFile parameter to identify the file from which to read. ReadFile begins reading at the location that is pointed to by the file pointer, and it continues reading up to the number of bytes that is specified in the nNumberOfBytesToRead parameter or to the end of the file. If ReadFile finds the end of the file, it does not return an error value. Instead, Readfile returns as much data as it reads up until the end of the file. Therefore, be sure to check the value returned in lpNumberOfBytesRead against the value passed to the function in nNumberOfBytesToRead. ReadFile returns the read data through the buffer that is pointed to in the lpBuffer parameter. During the copying process, Readfile does not perform any formatting or parsing; ReadFile reads the data exactly as the data exists in the file.

Note Windows CE does not support simultaneous read/write operations. Further, ReadFile does not support asynchronous read operations nor does it support read operations through a socket.