Chapter 5 — Printer Support
CN2B Mobile Computer User’s Manual 115
#define IOCTL_NPCP_IOCTL
CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x405,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_NPCP_PRTVER
CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x406,METHOD_BUFFERED,FILE_ANY_ACCESS)
• IOCTL_NPCP_CANCEL
This cancels all printing at the printer. It flushes the printer buffers and
re initializes the printer to its default state. No parameters are required.
• IOCTL_NPCP_BIND
This command is required before any data is sent or received by the
printer. Once the driver is opened, the application must bind the com-
munications session with the printer before any data can be sent or
received by the printer. If an error occurs during the bind, the applica-
tion may use IOCTL_NPCP_ERROR to get the current extended error
code. No parameters are required.
• IOCTL_NPCP_CLOSE
This command closes the current session with the printer. This function
always returns TRUE. No parameters are required.
• IOCTL_NPCP_ERROR
This command returns the extended NPCP error code in PL/N format.
The word returned will contain the PL/N compatible error code in the
low byte and completion flags in the high byte. If the frame that
returned an error was not received correctly by the printer the
FRAME_NOT_ACKED bit is set in the high byte. This operation
always returns TRUE. An output buffer of at least two bytes is required.
See “NPCP Error Codes” on page 116.
• IOCTL_NPCP_FLUSH
This command allows the application to poll the printer for errors while
the report is completing the print process at the printer. If an error
occurs during the polling process, the operation will return FALSE and
the application can get the extended error code by using
IOCTL_NPCP_ERROR. No parameters are required.
NPCP Printer Communications
All NPCP printer communications should be based on the following flow:
1 Use CreateFile(); to open the printer driver.
2 Use IOCTL_NPCP_BIND to bind a session with the printer;
IOCTL_NPCP_ERROR to check for errors on the bind to ensure suc-
cess; and IOCTL_NPCP_CANCEL to cancel outstanding print jobs.
3 Use IOCTL_NPCP_FLUSH to poll the printer to free up printer buffer
resources. Use IOCTL_NPCP_FLUSH to poll the printer’s status. If an
error is reported by the IOCTL, then use IOCTL_NPCP_ERROR to
get the error and determine the correct recovery procedure.
Kommentare zu diesen Handbüchern