BOOL (WINAPI *pfnWritePort)(
HANDLE hPort, | |
LPBYTE pBuffer, | |
DWORD cbBuf, | |
LPDWORD pcbWritten | |
); |
WritePort writes data to a port.
The return value is TRUE if the function is successful.
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.