WriteFile
WriteFile writes data to a file (synchronous operations only). The function starts writing data to the file at the position indicated by the file pointer. After the write operation has been completed, the file pointer is adjusted by the number of bytes written.
Syntax
BOOL WriteFile(
HANDLE hFile,
LPCVOID lpBuffer,
DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten,
LPOVERLAPPED lpOverlapped
);
Parameters
hFile
The file to be written to. The file handle must have been created with GENERIC_WRITE access to the file.
lpBuffer
A pointer to the buffer containing the data to be written to the file.
nNumberOfBytesToWrite
The number of bytes to write to the file.
Windows interprets a value of zero as specifying a null write operation. A null write operation does not write any bytes but does cause the time stamp to change.
lpNumberOfBytesWritten
A pointer to the number of bytes written by this function. WriteFile sets this value to zero before doing any work or error checking.
If lpOverlapped is NULL, lpNumberOfBytesWritten cannot be NULL.
lpOverlapped
Ignored.
Return Value
If the function succeeds, it returns TRUE; if the function fails, it returns FALSE.
To get extended error information, call GetLastError.
Remarks
eRTOS does not support asynchronous operations.
Applications must not read from nor write to the output buffer that a write operation is using until the write operation completes. Premature access of the output buffer may lead to corruption of the data written from that buffer.
Windows interprets zero bytes to write as specifying a null write operation and WriteFile does not truncate or extend the file.
Requirements
Minimum supported version | Header | Library |
---|---|---|
eRTOS 1.0 SDK |
windows.h | rtkrnl.lib |
See Also: