BOOL ReadPort( HANDLE hPort, LPBYTE pBuffer, DWORD cbBuf, LPDWORD pcbRead );
Reads data from the printer.
hPort | Handle of the port to read. |
pBuffer | Points to the buffer into which to read the data. |
cbBuf | Specifies the size, in bytes, of the buffer pointed to by the pBuffer parameter. |
pcbRead | The number of bytes read is put into the memory location pointed to by this parameter. |
The ReadPort function supports bi-directional printers. If there is any data in the printer, the ReadPort function returns all the data. If there is no response from the printer, the ReadPort function waits long enough to ensure that there is no data coming from the printer and then returns an error.
The port monitor ReadPort function is called by a language monitor, which is the only component of the spooler subsystem that is capable of interpreting the data read from the printer. A language monitor can create a thread to asynchronously call the port monitor ReadPort function to query unsolicited data from the printer at timed intervals of say, a few seconds.
The port monitor ReadPort function must not alter the data stream read from the printer in any way, but just return it to the language monitor caller for interpretation.
The printer driver that is associated with the language monitor that interprets the data read from the printer can get that information by calling the new Windows 95 GDI functions DrvGetPrinterData and DrvSetPrinterData. Following are guidelines for calling DrvGetPrinterData and DrvSetPrinterData in your printer driver: