Suppose I have a file on disk and then create its handle using CreateFile
, its mapping object using CreateFileMapping
, its mapping view using MapViewOfFile
. The start of the file address in virtual memory is held in pointer StartPtr
which was returned by MapViewOfFile
function. If, before calling CreateFileMapping
function, I use ReadFile
to read some bytes N
, would be the pointer returned by MapViewOfFile
point to ( StartPtr
+ N
) ?
No. MapViewOfFile() requires you telling it where the view is mapped relative from the start of the file. Specified in the dwFileOffset arguments. If you need it to work this way then simply use SetFilePointerEx() with a zero move to obtain the current position.
不, ReadFile仅移动磁盘文件指针。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.