Windows file: using both ReadFile and mapping

Suppose I have a file on disk, and then create its handle using CreateFileits mapping object using CreateFileMappingits mapping using MapViewOfFile. The beginning of the file address in virtual memory is stored in a pointer StartPtrthat was returned by the function MapViewOfFile. If CreateFileMappingI use ReadFilesome bytes to read before calling the function N, will there be a pointer returned by a MapViewOfFileperiod ( StartPtr+ N)?

+3
source share
2 answers

No. MapViewOfFile () requires that you tell it where the view is mapped relative to the beginning of the file. Indicated by dwFileOffset arguments. If you need it to work this way, just use SetFilePointerEx () with zero movement to get the current position.

+3
source

No. ReadFile moves only on the pointer on disk.

+2
source

All Articles