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 actually 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 (not supported by RTSS)
This parameter must be set to NULL.
Return Value
TRUE if the function succeeds, FALSE if the function fails
To get extended error information, call GetLastError.
Remarks
APIs that write to the RTX64 Console, including C/C++ Runtime library APIs, such as printf, std::cout, and std::cerr, may not return immediately in the following scenarios:
- When no user is logged on. This can happen when the RTX64 Subsystem is configured to start when Windows boots and if real-time applications are configured to start when the Subsystem starts.
- When a user is logged on via Remote Desktop Connection but disconnects before an RTX64 Console opens on the desktop of the remote session.
If real-time applications are expected to produce large amounts of console output, we recommend avoiding the scenarios listed above.
RTX64 does not support asynchronous operations.
If part of the file is locked by another process and the write operation overlaps the locked portion, this function fails.
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 | RTX64 2013 |
Header | windows.h |
Library | Rtx_Rtss.lib |
See Also: