Printer SupportChapter —5
164 700 Series Color Mobile Computer User’s Manual
Opening the NPCP Driver
The application opens the NPCP driver by using the CreateFile()
function. The call can be implemented as follows. The first parameter
“LPT9:”mustreflectthedevicenameandindexusedinthe
RegisterDevice() function call and will fail for any of the following reasons:
hFile = CreateFile(_T(”LPT9:”), GENERIC_WRITE |
GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,
NULL);
S The port associated with the device duri ng RegisterDevice() is in use.
S The NPCP device is already open.
S The share mode is not set to zero. The device cannot be shared.
S 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.
S TRUE = the dev ice is successf ully closed.
S FALSE = an attempt to close NULL HANDLE or 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 be performed. 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
following I/O control codes are defined:
Comentarios a estos manuales