Programming Considerations for USBPRINT

Usbprint.sys, together with USBMON, provides an interface very similar to that used by parallel printers. In many cases, it is possible for a single printer driver or language monitor to work correctly on both parallel and USB printers without modification. If a language monitor uses only the WritePort and ReadPort functions and the IOCTL_PAR_QUERY_DEVICE_ID request, it will be portable between USB and parallel printers.

In some cases, it might be necessary for a language monitor to make vendor-specific requests to a printer in order to take advantage of special printer features. To do this, use IOCTL_USBPRINT_VENDOR_SET_COMMAND and IOCTL_USBPRINT_VENDOR_GET_COMMAND. Note, however, that using these IOCTLs renders a language monitor incompatible with the parallel port monitor.

Language monitors normally do not have access to a device handle for the printer they are managing. Instead, they have a port name provided by the port monitor that sits between the language monitor and the bus driver (Usbprint.sys in this case). See Language and Port Monitor Interaction for more information. The lack of a device handle prevents language monitors from directly calling device bus driver IOCTLs. To overcome this limitation, USBMON implements the GetPrinterDataFromPort API, which allows language monitors to issue IOCTLs through USBMON to USBPRINT.

The USB printing stack shares the following APIs and IOCTL with the parallel printing stack:

WritePort

ReadPort

IOCTL_PAR_QUERY_DEVICE_ID

The following IOCTLs are specific to the USB printing stack:

IOCTL_USBPRINT_GET_1284_ID

IOCTL_USBPRINT_GET_LPT_STATUS

IOCTL_USBPRINT_SOFT_RESET

IOCTL_USBPRINT_VENDOR_GET_COMMAND

IOCTL_USBPRINT_VENDOR_SET_COMMAND

Note Usbprint.sys does not provide a mechanism for obtaining descriptors from the device, nor for directly manipulating USB pipes.