[New for Windows NT 4.0 Service Pack 2.]
The WriteFileGather function gathers data from a set of buffers and writes the data to a file.
The WriteFileGather function starts writing data to the file at a position specified by an OVERLAPPED data structure.
The WriteFileGather function operates asynchronously.
BOOL WriteFileGather(
HANDLE hFile, |
// handle to a file to write data to |
FILE_SEGMENT_ELEMENT aSegmentArray [], |
// pointer to an array of buffer pointers |
DWORD nNumberOfBytesToWrite, |
// number of bytes to write |
LPDWORD lpReserved, |
// reserved; must be NULL |
LPOVERLAPPED lpOverlapped |
// pointer to an asynchronous I/O data structure |
); |
This file handle must have been created using GENERIC_WRITE to specify write
access to the file, FILE_FLAG_OVERLAPPED to specify asynchronous I/O, and
FILE_FLAG_NO_BUFFERING to specify non-cached I/O.
Each buffer should be the size of a system memory page. Each buffer should be aligned on a system memory page size boundary.
A FILE_SEGMENT_ELEMENT pointer is a 64-bit value. The WriteFileGather function uses all 64 bits. Since the operating systems do not currently support 64-bit memory addressing, you must explicitly zero the upper 32 bits of each FILE_SEGMENT_ELEMENT pointer.
The function gathers the data from the buffers in a sequential manner: it writes data to the file from the first buffer, then from the second buffer, then from the next, until there is no more data to write.
The final element of the array should be a NULL pointer.
Note that this behavior differs from file writing functions on the MS-DOS platform, where a write count of zero bytes truncates a file. WriteFileGather does not truncate or extend the file. To truncate or extend a file on the Windows NT platform, use the SetEndOfFile function..
The WriteFileGather function requires a valid OVERLAPPED structure. The lpOverlapped parameter cannot be NULL.
The WriteFileGather function starts writing data to the file at a position specified by the offset and offsetHigh members of the OVERLAPPED structure.
The WriteFileGather function may return before the write operation has completed. In that case, the WriteFileGather function returns the value zero, and the GetLastError function returns the value ERROR_IO_PENDING. This asynchronous operation of WriteFileGather lets the calling process continue while the write operation completes. You can call the GetOverlappedResult, HasOverlappedIoCompleted, or GetQueuedCompletionStatus function to obtain information about the completion of the write operation.
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call the GetLastError function.
If the function returns before the write operation has completed, the function returns zero, and GetLastError returns ERROR_IO_PENDING.
If part of the file specifed by hFile is locked by another process, and the write operation overlaps the locked portion, the WriteFileGather function fails.
CreateFile, GetOverlappedResult, GetQueuedCompletionStatus, HasOverlappedIoCompleted, OVERLAPPED, ReadFile, ReadFileEx, ReadFileScatter
file: /Techref/os/win/api/win32/func/src/f92_23.htm, 6KB, , updated: 2000/4/7 11:19, local time: 2024/11/27 15:52,
3.145.33.244:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/Techref/os/win/api/win32/func/src/f92_23.htm"> WriteFileGather</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.