KsWriteFile

The availability of this function depends on what the device supports.

Writes data to a COM port.

Syntax

BOOL KsWriteFile(
     HANDLE hFile,
     LPCVOID lpBuffer,
     DWORD nNumberOfBytesToWrite,
     LPDWORD lpNumberOfBytesWritten,
     LPOVERLAPPED lpOverlapped
);

Parameters

hFile: the port to be written to.

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. KsWriteFile 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

If the function succeeds, it returns TRUE, otherwise FALSE. To get extended error information, call GetLastError.

Remarks

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 KsWriteFile does not truncate or extend the file.

Example

N/A

Requirements

  RT Win32
Minimum supported version 4.0 4.0
Header kscom.h kscom.h
Library KsApi_Rtss.lib ksapi.h

See also

KsReadFile