Windows NT provides printer driver extensions that allow you to optionally implement a user-mode printer driver. These extensions allow a printer driver to implement rendering functionality in user mode by allowing the driver to alter the data stream both before it is sent to the kernel-mode printer driver and after it is returned from the kernel-mode printer driver.
If implemented, the user-mode printer driver should exist as a separate module from the printer interface driver. In this situation, the user-mode printer driver must link to spoolss.lib, as opposed to winspool.lib.
When the spooler calls DrvPrinterEvent with PRINTER_EVENT_INITIALIZE, the printer interface driver should call the Win32 SetPrinterData function with a value of SPLPRINTER_USER_MODE_PRINTER_DRIVER and a REG_SZ value that is the name of the DLL. The spooler will then know which DLL to load during printing.
Sample code for a simple user-mode printer driver is provided with this Windows NT DDK. Function declarations can be found in winddiui.h, which is also provided with the DDK. The following table lists the functions that comprise this interface, and identifies those functions that must be implemented.
DrvSplAbort | Aborts the printing job. Optional. |
DrvSplClose | Releases the user-mode printer driver handle and its associated resources. Required. |
DrvSplEndDoc | Ends the printing job. Required. |
DrvSplEndPage | Provides end-of-page notification. Optional. |
DrvSplStartDoc | Starts the identified print job. Required. |
DrvSplStartPage | Prepares the printer to accept data. Optional. |
DrvSplWritePrinter | Writes data to the printer. Required. |