Chapter 5 — Printer Support
114 CN2B Mobile Computer User’s Manual
• The port associated with the device during RegisterDevice() is in use.
• The NPCP device is already open.
• The share mode is not set to zero. The device cannot be shared.
• Access permissions are not set to GENERIC_WRITE |
GENERIC_READ. Both modes must be specified.
Closing the NPCP Driver
Using the CloseHandle() (hFile) function closes the NPCP driver. Where
hFile is the handle returned by the CreateFile() function call.
• TRUE = the device is successfully closed.
• FALSE = an attempt to close NULL HANDLE or an already closed
device.
Reading from the NPCP Driver
Reading of the NPCP printers is not supported since all responses from the
printer are the result of commands sent to the printer. DeviceIoControl()
functions are provided where data is to be received from the printer.
Writing to the NPCP Driver
All Print data can be sent to the printer using the WriteFile() function. The
print data written to the driver must contain the proper printer commands
for formatting. If the function returns FALSE, the NPCP error may be
retrieved using IOCTL_NPCP_ERROR. See the description on the next
page.
NPCP Driver I/O Controls
An application uses the DeviceIoControl() function to specify an printer
operation to perform. Certain I/O controls are required to bind and close
communication sessions with the printer, and must be completed before
any other commands to the driver can execute properly.
The function returns TRUE to indicate the device successfully completed
its specified I/O control operation, otherwise it returns FALSE. The follow-
ing I/O control codes are defined:
#define IOCTL_NPCP_CANCEL
CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x400,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_NPCP_BIND
CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x401,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_NPCP_CLOSE
CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x402,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_NPCP_ERROR
CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x403,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_NPCP_FLUSH
CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x404,METHOD_BUFFERED,FILE_ANY_ACCESS)
Comentarios a estos manuales