8.10
S
CAN
G
ET
D
ATA
()
Prototype:
SCAN_RESULT ScanGetData(HANDLE hScanner, TCHAR * lpBuff, LPINT BufSize);
Purpose:
Returns scanned data after a successful read operation on the scanner device.
Arguments:
[in] hScanner is the value received by the client application in lParam of the WM_INSERTION
message specified when ScanInit() was called.
If the application program doesn’t support callbacks, use 1 for the HANDLE (if multi-scanner
disabled) .
[out] lpBuff points to the buffer to receive the scanned data.
[in/out] BufSize points to the size of the buffer in bytes (not characters). Upon return, BufSize will
be set to the number of bytes written into lpBuff. This can be converted to a character count by
dividing BufSize by sizeof(TCHAR). Typically the buffer size will be equal to the character count on
Win32 Desktop systems.
Notes:
ScanGetData() should be called in response to receiving the WM_SCANNERDATA message. The
data returned will be in UNICODE on CE devices.
It is possible for NULL characters to appear in the scanned data, depending on the symbology
scanned by the user. Also note that the ScanAPI DLL will not NULL-terminate the scanned data.
Therefore, do all necessary validity checks on the buffer before you do anything with the data.
Once the data is validated, you can add your own prefix or suffix, add your own terminating NULL,
or perform any other pre-processing to the data stream you desire.
To discover the size of the data available without actually retrieving it from the scanner, you may
use NULL as the lpBuff argument – in this case BufSize will be filled in with the size of the data and
the function will return successfully. If lpBuff is not NULL and the buffer is too small, no data
transfer will take place, the size of the buffer necessary will be written to BufSize, and the function
will return SR_BUFFER_TOO_SMALL. At this point you MUST call ScanGetData() again with a larger
buffer to remove the data and allow for continued scanning.
Applications should respond to the WM_SCANNERDATA message as soon as possible. The ScanAPI
DLL has a small buffer for storing multiple scans (currently 16 scans), in case the user is scanning
data more quickly than your application can process it. But when this buffer fills, additional
scanned data will be discarded, and no notifications of the overflowed data will be sent.
If the application program doesn’t accept callback events, calling ScanGetStatus() will return status
of the scanner along with data available status.
For RFID this function is called to get the tag ID as a result of a ScanTrigger() call. The data is
returned is one of TagID, Tag Data, or TagID and Tag Data. For example it could return just the
TagID as an ASCII string containing the tag type followed by a “:” and the tag ID.
As an example, an ISO 15693 tag with an ID of E007000001476301, would be returned in 19 bytes
as:
April 8, 2010
Page 34
Document#: 6410-00147 K
Revision 2.28