PrinterSupportChapter —5
200 700Series Color MobileComputer User’s Manual
Opening the NPCP DriverTheapplicationopenstheNPCPdriverbyusingtheCreateFile()
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);
SThe port associatedwith the device during RegisterDevice() is in use.
SThe NPCP device is alreadyopen.
SThe share modeis not set to zero. The device cannot be shared.
SAccess permissions are not set to GENERIC_WRITE |
GENERIC_READ. Both modes must be specified.
Closing the NPCP DriverUsing the CloseHandle()(hFile) function closes the NPCP driver. Where
hFile is the handle returned by the CreateFile() function call.
STRUE = the device is successfully closed.
SFALSE = an attempt to close NULL HANDLE or an already closed de-
vice.
Reading from the NPCP DriverReadingof the NPCP printers is not supported since all responsesfrom
the printer arethe result of commands sent to the printer.
DeviceIoControl()functions are provided where data isto be received
from the printer.
Writing to the NPCP DriverAll Print data can be sent to the printer using the WriteFile() function.
The print data written to the driver must contain the proper printer
commandsfor formatting. If the function returns FALSE, the NPCPerror
may be retrieved usingIOCTL_NPCP_ERROR. See the description on
the next page.