WritePrinter


BOOL WritePrinter(
    HANDLE  hPrinter,
    LPVOID  pBuf,
    DWORD   cbBuf,
    LPWORD  pcWritten
);

The Microsoft-provided local print provider WritePrinter function writes raw data from a specified buffer location to a specified printer.

Returns TRUE if successful; FALSE otherwise.

hPrinter

Specifies the name of the printer to which to write the raw data. Identifies an open printer associated with the print processor and must be obtained from a call to OpenPrinter before WritePrinter is called. You must also call StartDocPrinter before the call to WritePrinter. Before making the StartDocPrinter call, set the dwMode member of the DOC_INFO_2 structure to DI_CHANNEL_WRITE to write the given raw data to the port the specified printer is associated with (this may be either a local port or a network port). See the comments in the ReadPrinter function definition for a definition of the DOC_INFO_2 structure.

pBuf

Points to the buffer that contains the raw data to be written to the printer.

cbBuf

Number of characters to print from the buffer.

pcWritten

Points to the variable in which the WritePrinter function returns the number of characters successfully written to the printer.