ReadPrinter


BOOL ReadPrinter(
    HANDLE  hPrinter,
    LPVOID  pBuf,
    DWORD   cbBuf,
    LPWORD  pNoBytesRead
);

The Microsoft-provided local print provider ReadPrinter function either reads data from a bi-directional printer or reads data from a spool file.

Returns TRUE if successful; FALSE otherwise.

hPrinter

Identifies an open printer associated with the print processor and must be obtained from a call to OpenPrinter before ReadPrinter is called. You must also call StartDocPrinter before the call to ReadPrinter and the setting of the dwMode member of the DOC_INFO_2 structure when the StartDocPrinter function call is made modifies the meaning of the subsequent ReadPrinter call. See the comments below for example code that illustrates how these function calls work together. If the dwMode member is set to DI_READ_SPOOL_JOB when the StartDocPrinter call is made, then the subsequent ReadPrinter call will read the spool file (which may contain either raw or EMF data). If dwMode is not set to DI_READ_SPOOL_JOB, then the subsequent ReadPrinter call will read status information from a bi-directional printer.

pBuf

Points to the buffer into which the data is read.

cbBuf

The size of the buffer (number of characters in the buffer).

pNoBytesRead

Points to a variable into which the ReadPrinter function puts the number of characters successfully read from the printer or spool file.


The ReadPrinter function call is always preceded by a call to the StartDocPrinter call. If you set the dwMode member of the DOC_INFO_2 structure to DI_READ_SPOOL_JOB before making the StartDocPrinter function call, the subsequent ReadPrinter function call will read the spool file identified in the pOutput member of the DOC_INFO_2 structure instead of reading status information from the bi-directional printer your print processor is associated with.

The structure definition for the DOC_INFO_2 structure is shown below.


typedef struct _DOC_INFO_2
{
   LPTSTR    pDocumentName;  //identifies document being printed
   LPTSTR    pOutputFile;    //identifies spool file
   LPTSTR    pDatatype;      //data type of spooled file
   DWORD     dwMode;         //flags
   DWORD     JobId;          //identifies print job being printed
}DOC_INFO_2;