INtime SDK Help
INtime SDK v7.1 > About INtime > INtime Kernel > Files > WriteRtFile

Writes data to the specified file or device. Data may be written asynchronously or synchronously.

BOOLEAN WriteRtFile(
LPVOID lpBuffer,
DWORD cbBufferSize,
LPDWORD lpcbBytesWritten,


A handle for a file object
A pointer to a contiguous buffer where the data is stored.
The size in bytes of the buffer
A pointer to a variable where the number of bytes written in the operation is actually stored (synchronous operation only).
A pointer to an ASYNCIOH structure which has been initialized, or NULL if the operation is to be synchronous.


A synchronous operation is started by supplying NULL for the lpAsynch parameter, and returns after the operation is complete, or an error was detected. If the operation was successful, and a non-null value has been provided for lpcbBytesWritten, then the actual count of bytes written is returned through that pointer.

An asynchronous operation is started by supplying a pointer to an initialized ASYNCIO structure in the lpAsync parameter, and the function returns after the parameters have been verified and the write operation has been started but before the entire operation has completed.

The structure must be initialized with at least a handle for a data mailbox through which the ASYNCIO structure is returned on completion of the operation. To complete the operation, wait on the mailbox for the structure to be returned, or call WaitForRtIo with the file handle and the same async pointer supplied to the WriteRtFile call.

Note: Asynchronous file operations are not currently supported on INtime Distributed RTOS

Return value

TRUE on success. FALSE on failure. Possible failures include the following (returned from GetLastRtError()):

Status value Meaning
E_EXIST The handle provided is not a valid handle
E_TYPE The handle provided is not a handle for a file
E_PARAM The file was opened in asynchronous mode, but the lpAsync parameter is NULL, or the file was opened in synchronous mode and the lpAsync parameter is not NULL.
E_IO_HARD An I/O error occurred during the operation
E_BAD_BUF The buffer address is invalid
E_CONN_NOT_OPEN The handle provided does not refer to an open file
E_SLOT No more GDT slots are available. This can occur when a very large number of asynchronous operations are outstanding.
E_NOT_CONFIGURED Call is not supported in INtime Distributed RTOS.


Versions Defined in Include Link to
INtime 6.0 intime/rt/include/rtbase.h rt.h rt.lib

See Also