Equivalent to pread/pwrite in MSVC?

什么叫MSVC 10中最好的模拟pread / pwrite?


At the C runtime library level, look at fread, fwrite and fseek.

At the Win32 API level, have a look at ReadFile, WriteFile, and SetFilePointer. MSDN has extensive coverage of file I/O API's.

Note that both ReadFile and WriteFile take an OVERLAPPED struct argument, which lets you specify a file offset. The offset is respected for all files that support byte offsets, even when opened for synchronous (ie non 'overlapped') I/O.

Depending on the problem you are trying to solve, file mapping may be a better design choice.


It looks like you just use the lpOverlapped parameter to ReadFile / WriteFile to pass a pointer to an OVERLAPPED structure with the offset specified in Offset and OffsetHigh .

(Note: You don't actually get overlapping IO unless the handle was opened with FILE_FLAG_OVERLAPPED .)

链接地址: http://www.djcxy.com/p/72520.html

上一篇: MSVC相当于

下一篇: 等同于MSVC中的pread / pwrite?