PrinterSupportChapter 5
205700Series Color Mobile Computer User’sManual
Opening the DTR Driver
The applicationopens the DTR driver by using the CreateFile() function.
The call can be implemented as follows:
hFile = CreateFile(_T(”DTR1:”), GENERIC_WRITE, 0, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
The first parameter “DTR1:” must reflect the device name and index u sed
in the RegisterDevice() function call.
The function call will fail for any of the following reasons:
SThe port associatedwith the device during RegisterDevice() is currently
in use.
SThe DTR device is already open.
SThe share modeis not set to zero. The device cannot be shared.
SAccess permissions are not set to GENERIC_WRITE.
Closing the DTR Driver
Using the CloseHandle()(hFile) function closes the DTR driver. Where
hFile is the handle returned by the CreateFile() function call.
STRUE indicates the device is successfully closed.
SFALSE indicates an attempt to close a NULL HANDLE or an already
closed device.
Writing to the DTR Driver
You can use the WriteFile() function to sendall Print data to the printer.
The print data being written must contain the prope r formatting printer
commands.
DTR Printer Communications
All DTR printer communications should be based on the following flow:
1Use CreateFile()to open the printer driver.
2Use WriteFile()to write your data to the printer. Check for errors and
that all data were written.
3Use CloseHandle() to close the driver.