BOOL (WINAPI *pfnWritePort)(
HANDLE hPort, | |
LPBYTE pBuffer, | |
DWORD cbBuf, | |
LPDWORD pcbWritten | |
); |
WritePort writes data to a port.
Parameters
hPort
Identifies the port to which the data should be written.
pBuffer
Points to a buffer that contains data to be written to the port.
cbBuf
Specifies the size, in bytes, of pBuffer.
pcbWritten
Points to a location in which the number of bytes successfully written to the port will be written.
Return Value
The return value is TRUE if the function is successful.
Comments
WritePort sends the data pointed to by pBuffer to the printer. The spooler calls WritePort as often as is necessary to send an entire print job to the printer. The spooler sets the block size specified by cbBuf, so a monitor should not make any assumptions about it.
If there is no response from the printer, WritePort should wait a reasonable amount of time and then returns FALSE. WritePort should always initialize pcbWritten to zero before attempting the port write. If the port write succeeds, pcbWritten should be overwritten with the number of bytes sent. Note that a port can return zero bytes on a successful write; WritePort should return TRUE in this situation.
A language monitor can add information to the data stream before sending it to the port monitor’s WritePort routine for printing.
Language monitors might call a port monitor’s WritePort routine outside of a StartDocPort/EndDocPort pair. Port monitors that do not allow this can fail the call, and language monitors should be written to handle such a failure.
WritePort must be implemented by both port and language monitors.