Socket SocketScan SDK User manual

SocketScan™SDK User’s Guide
&
ScanAPI: Scanning Application Program Interface
Document # 6410-00147 K
April 8, 2010

4/2010 Document # 6410-00147 K
Copyright Notice
Copyright © 1999-2010 Socket Mobile, Inc. All rights reserved.
Socket, the Socket logo, Mobility Friendly, SocketScan, Socket Bluetooth Cordless Ring Scanner, Socket
Bluetooth Cordless Hand Scanner, CF Scan Card, SD Scan Card, CF Mag Stripe Reader Card, CF RFID Reader
Card, and CF RFID Reader-Scan Card are registered trademarks or trademarks of Socket Mobile, Inc. The
Bluetooth word mark and logo are registered trademarks of the Bluetooth SIG, Inc., USA, and any use by
Socket Mobile is under license. All other brand and product names are trademarks of their respective holders.
Reproduction of the contents of this manual without the permission of Socket Mobile is expressly prohibited.
Please be aware that the products described in this manual may change without notice.
Feel free to contact Socket Mobile at:
Socket Mobile, Inc.
39700 Eureka Drive
Newark, CA 94560
USA
Web: www.socketmobile.com/contact
Phone: +1-510-933-3000
USA & Canada Toll-free: 1-800-552-3300
Other than the above, Socket Mobile can assume no responsibility for anything resulting from the
application of information contained in this manual.
You can track new product releases, software updates and technical bulletins by visiting:
www.socketmobile.com.
April 8, 2010 Page 2
Document#: 6410-00147 K Revision 2.28

Revision History
Revision Date Author Comments
1.00 10/26/1999 G. Cuevas, L. Ott Genesis.
1.01 11/01/1999 G. Cuevas, J. Houston Updated registry section; added correct doc number; cleaned up typos,
etc.
1.02 11/02/1999 G. Cuevas, L. Ott Additional corrections.
1.03 11/04/1999 G. Cuevas Changed keyboard wedge product name to SocketScan.
1.04 11/04/1999 G. Cuevas Corrected registry entry section.
1.05 11/13/1999 G. Cuevas Updated for disk layout change.
2.00 03/29/2000 G. Cuevas Additions for Win32 Desktop, Preview DLL, Bar Code Wand.
2.01 05/06/2000
G. Cuevas, P. Subbaraya,
J. Houston General edits and corrections.
2.02 05/10/2000 G. Cuevas, P. Subbaraya Additional edits.
2.03 05/12/2000 G. Cuevas, P. Subbaraya Additions and corrections.
2.04 05/15/2000
G. Cuevas, P. Subbaraya,
J. Houston Minor edits.
2.05 05/17/2000 G. Cuevas, P. Subbaraya Minor edits.
2.06 05/23/2000 G. Cuevas, P. Subbaraya Additional minor changes.
2.07 12/11/2000 G. Cuevas Updates for HPC 2000, Windows 2000 and Windows Me.
2.08 12/20/2000 G. Cuevas, M. Man Minor edits.
2.09 12/20/2000 G. Cuevas Minor edits.
2.10 9/27/2001 T. Newman Changes for SocketScan 3.2. Added ScanGetStatus() API call (WinCE).
Polling calls from Embedded Visual Basic (EVB). Minor edits to API calls.
2.11 12/17/2002 D. Acquistapace Added ScanParamSend and ScanParamRequest API calls (WinCE).
2.12 12/23/2002 P. Subbaraya Changes for SocketScan 4.0 to support the 2DSC for bar code. Minor
edits
2.13 07/11/2003 P. Subbaraya Changes for SocketScan 4.0 to support the 2DSC
ScanSendCommand() API call(WinCE.)
2.14 01/22/2004 P. Subbaraya Changes for SocketScan 4.1.xx to support DriverMan registry structure.
Minor edits.
2.15 08/11/2004 D. Singh, S. Gutti Updated CHS information, modified desktop information
2.16 08/30/2004 T. Newman RFID Reader functions added
2.17 10/28/2004 S. Gutti Updated CHS information for Windows XP.
2.18 11/16/2004 D. Singh Added SDK Quick Start guide
2.19 12/08/2004 D. Singh Update ScanGetData() details and Section 4 and 12 for specific DLLs
2.20 01/07/2005 S. Gutti Add new APIs for CHS configuration commands in Section 8.0 & 9.0 and
updated registry entry section
2.21 03/17/2005 S. Gutti Updated ScanEnableCHS() & ScanDisableCHS() APIs
2.22 06/09/2005 S. Gutti Added new APIs to handle symbologies for all Scanners
2.23 09/23/2005
A. Hersh, D. Singh,
T. Newman, M. Man
Added CF RFID Reader-Scan Card APIs, CHS programming info, and
SocketScan Trigger Applications
2.24 01/27/2006 A. Hersh Minor edits to reflect WM 5.0 support, MSR and CRS.
2.25 08/22/2006 A. Hersh Minor edits
2.26 11/29/2007 D. Acquistapace Edited for 5X support and new SDK directory structure
2.27 10/02/2008 E. Glaenzer Added ScanCommandFeature API to support the RFID AFI feature.
2.28 4/7/10 E. Glaenzer Added ScanCheckVersion API, and the Scanner Property APIs. Added a
paragraph regarding ActivePairing and Permanent Pair features.
April 8, 2010 Page 3
Document#: 6410-00147 K Revision 2.28

Table of Contents
1.0 Introduction .....................................................................................................................................7
1.1 SDK Quick Start Guide ............................................................................................................8
2.0 Revision Notes..................................................................................................................................9
2.1 Windows CE.............................................................................................................................9
2.2 Windows Desktop/Notebook .................................................................................................9
3.0 Using ScanAPI.................................................................................................................................11
3.1 SDK Initialization/De-initialization ......................................................................................11
3.2 Device Control.......................................................................................................................11
3.3 Scanner Data Access..............................................................................................................11
3.4 Miscellaneous Utility.............................................................................................................11
3.5 Cordless Scanner Specific Functions.....................................................................................12
3.6 RFID Specific Functions .........................................................................................................12
4.0 Setting Up The Target Device .......................................................................................................13
4.1 Setting up Windows CE Devices...........................................................................................13
5.0 Writing Your Application..............................................................................................................14
5.1 Preview DLL ...........................................................................................................................15
5.2 RFID Demo.............................................................................................................................15
5.3 ScanApiTester........................................................................................................................15
5.4 TriggerSample .......................................................................................................................15
5.5 CSharp Sample ......................................................................................................................15
5.6 Combo Card CSharp Sample.................................................................................................15
5.7 RFID VB ..................................................................................................................................15
5.8 VB Sample..............................................................................................................................15
6.0 Soft Triggering...............................................................................................................................17
7.0 ScanAPI Type Reference ................................................................................................................18
8.0 ScanAPI Function Reference..........................................................................................................21
8.1 ScanCheckVersion .................................................................................................................21
8.2 ScanInit()................................................................................................................................22
8.3 ScanOpenDevice() .................................................................................................................24
8.4 ScanCloseDevice()..................................................................................................................25
8.5 ScanGetDevInfo() ..................................................................................................................26
8.6 ScanGetStatus() .....................................................................................................................28
April 8, 2010 Page 4
Document#: 6410-00147 K Revision 2.28

8.7 ScanRequestDataEvents() .....................................................................................................29
8.8 ScanTrigger() .........................................................................................................................31
8.9 ScanAbort()............................................................................................................................33
8.10 ScanGetData() .......................................................................................................................34
8.11 ScanSetGoodReadSound() ....................................................................................................36
8.12 ScanDeinit() ...........................................................................................................................37
8.13 ScanErrToText() .....................................................................................................................38
8.14 ScanParamSend()...................................................................................................................39
8.15 ScanParamRequest() .............................................................................................................41
8.16 ScanSendCommand() ............................................................................................................42
8.17 ScanCommandFeature() .......................................................................................................43
8.18 ScanParamSendEx()...............................................................................................................45
8.19 ScanParamRequestEx()..........................................................................................................47
8.20 IsScannerConnected() ...........................................................................................................48
8.21 IsScannerConnectedEx()........................................................................................................48
8.22 ScanEnableDisableSymbology() ...........................................................................................49
8.23 ScanReadSymbologyConfig() ...............................................................................................50
8.24 ScanWriteSymbologyConfig() ..............................................................................................51
8.25 ScanEnableMultiScanner()....................................................................................................51
8.26 ScanGetScannerRegKey ().....................................................................................................52
8.27 ScanOpenScannerProperty ...................................................................................................53
8.28 ScanCloseScannerProperty ...................................................................................................53
8.29 ScanGetScannerProperty ......................................................................................................53
8.30 ScanSetScannerProperty .......................................................................................................54
8.31 Property identifiers ...............................................................................................................54
8.32 Sample symbology config code:...........................................................................................58
8.32.1 Sample Code to Enable or Disable CODE39 symbology:.........................................58
8.32.2 Sample code for Read configuration: ......................................................................58
8.32.3 Sample Code to Enable or Disable CODE39 symbology:.........................................59
9.0 Cordless Scanner (CS) Specifics......................................................................................................60
9.1 ScanEnableCHS() ...................................................................................................................61
9.2 ScanDisableCHS()...................................................................................................................62
9.3 ScanSendCmdtoCHS() ...........................................................................................................63
9.4 Bluetooth Connection Status ...............................................................................................65
April 8, 2010 Page 5
Document#: 6410-00147 K Revision 2.28

April 8, 2010 Page 6
Document#: 6410-00147 K Revision 2.28
9.5 CHS Commands .....................................................................................................................66
9.5.1 Set Security Mode .....................................................................................................66
9.5.2 Set Friendly Name .....................................................................................................66
9.5.3 Set PIN Code ..............................................................................................................66
9.6 CHS Control commands ........................................................................................................67
9.6.1 Set Indicators .............................................................................................................67
9.6.2 Battery Charge State Inquiry ....................................................................................67
9.6.3 Battery Charge State Response ................................................................................67
9.6.4 Friendly Name Inquiry...............................................................................................67
9.6.5 Friendly Name Response...........................................................................................68
9.7 Registry Settings for the Cordless Hand Scanner ................................................................69
10.0 RFID Reader....................................................................................................................................71
11.0 MultiScanner Support (WIN CE ONLY) .........................................................................................72
11.1 Registry Settings for the CF RFID Reader-Scan Card ...........................................................72
12.0 Using SocketScan (Keyboard Wedge)...........................................................................................74
13.0 SocketScan Trigger Applications (WINCE ONLY) .........................................................................75
13.1 Triggering Details .................................................................................................................76
13.2 Changing the Active Scanner ...............................................................................................77
14.0 The DriverMan dll ..........................................................................................................................78
14.1 Implementing a SocketScan Preview DLL............................................................................79
15.0 Implementing a SocketScan Application in .NET.........................................................................81
16.0 Symbology Support by Scanner Type ...........................................................................................82

1.0 INTRODUCTION
Note: In this document, the word “scanner” refers to any Socket data collection device, and the
word “scan” refers to a bar code scan, RFID read or magnetic stripe read, unless otherwise noted.
The Socket ScanAPI is a set of Windows CE and Win32 Desktop DLLs that offer access to the complete line of
data collection products from Socket:
•Secure Digital Scan Card Series 3
•CompactFlash Mag Stripe Reader Card Series 4
•CompactFlash Scan Card Series 5
•CompactFlash RFID Reader Card Series 6
•Socket Bluetooth® Cordless Hand Scanner Series 7
•Socket Bluetooth® Cordless Ring Scanner Series 9
By using the ScanAPI, applications can easily perform the following functions:
•Receive notification of the insertion or removal of a plug-in data collection device or the connection or
disconnection of a wireless data collection device
•Determine the type and properties of data collection devices inserted
•Trigger (and abort) scanning/reading on supported devices that do not have a hardware trigger
•Receive notification of data available from the scanner/reader
•Configure end-user good-read acknowledgement using a beep or by playing a .wav file
Since ScanAPI returns the data block read from the scanner/reader, it is a simple matter for applications to
pre-process the data before its final disposition. Applications may add a prefix or a suffix to the data, and
perform any other application-specific character translations, insertions or deletions, if desired.
A version of the Socket keyboard wedge software, “SocketScan,” is based on the ScanAPI. It is included in
versions for each supported platform on the SDK CD and may also be downloaded from the Socket web site
at www.socketmobile.com. Its features include:
•Recognition of the entire line of Socket data collection products
•Flexible addition of prefix and/or suffix to the scanned/read data
•Configuration of a good-read acknowledgement sound
•A “silent mode” allowing VARs to run the wedge software in the background, making it invisible to the
user (for Windows CE only)
•Registry entries allowing VARs to configure the prefix, suffix, sounds, and other properties at install-time
using their own custom installer
•A “Preview DLL” can be registered with the wedge, allowing developers to preview and modify data
scanned by the user
All binary files for the SocketScan program may be freely distributed by the Developer, for use with Socket
data collection products. The documentation supplied is protected via copyrights held by their respective
owners and cannot be distributed without written permission.
© Socket Mobile, Inc. October 2, 2008 Page 7
Document#: 6410-00147 J Revision 2.24

The term “scanned data” is used throughout this document and generally describes data scanned from a bar
code or data returned from reading a RFID tag.
1.1 SDK QUICK START GUIDE
1) Read Chapters 3 and 8 of this User’s Guide to understand the Scanner APIs
2) Read Chapter 5 to understand the sequence of events and messages for the API
3) Based on your requirements, examine the Sample code provided
4) Read Chapter 6 to learn how to trigger your scanner
5) Read Chapter 4 and the Targeted Scanner Deployment document to understand DLL and
registry requirements.
You should now be ready to add support for any Socket data collection products to your Windows
application.
If needed, please refer to Section 12.2 for a sample of how install your application on the target
device.
April 8, 2010 Page 8
Document#: 6410-00147 K Revision 2.28

2.0 REVISION NOTES
Although ScanAPI is a thin layer, it is designed for future expansion while also being backwards compatible
with existing applications. As new data collection devices with new functionality are supported, the ScanAPI
will be expanded to support these new features, while leaving the existing API function interfaces
unchanged. Whenever possible, all compatible data collection devices will support the standard ScanAPI
mechanism for triggering and retrieving scanned data. This allows devices such as the CF RFID Reader Card
to function like a standard bar code scanner even though the RFID reader’s capabilities are more extensive
than those of a bar code scanner, with both writing and reading capabilities.
WARNING: Do NOT attempt to change any communication protocol settings or scan any “Set All
Defaults” programming bar code with any Socket data collection product unless instructed to do
so by Socket Technical Support.
IMPORTANT: ScanAPI currently assumes that the communication parameters for the data
collection devices have not been changed from their factory defaults. If the baud rate, word size,
etc. have been changed from the factory defaults, they will have to be manually restored before
the device will work with ScanAPI. If this happens to the CF Scan Card Series 5 or SD Scan Card
Series 3, it must be returned to the factory to restore default communication settings. The
SocketScan keyboard wedge program also expects that the attached data collection device has
not been programmed to produce prefix or suffix characters.
The SocketScan keyboard wedge application supplied with the SDK offers a powerful feature for developers.
A “Preview DLL” can be written and registered with the SocketScan application. This DLL will see the block
of scanned data before the data is submitted to the keyboard buffer. This provides the developer an
opportunity to validate, pre-process or perform various other modifications on the scanned data. In cases
where the keyboard wedge software is very close, but not quite perfect for your custom application’s data
collection solution, we believe this new feature may provide many with the opportunity to make it so –
quickly, simply and effectively.
If you plan to deploy a large number of data collection devices along with your application, please contact
Socket to explore the possibility of having the devices programmed to your specifications during
manufacturing. We can ensure that certain symbologies are enabled or disabled, and we can pre-program
devices in various other ways to suit your needs.
2.1 WINDOWS CE
This release includes support for Windows CE 4.2 devices up to Windows CE 6.1. The following data
collection products are supported:
•Secure Digital Scan Card (SDSC) Series 3
•CompactFlash Mag Stripe Reader Card (MSR) Series 4
•CompactFlash Scan Card (CFSC) Series 5
•CompactFlash RFID Reader Card Series 6
•Socket Bluetooth Cordless Hand Scanner (CHS) Series 7
•Socket Bluetooth Cordless Ring Scanner (CRS) Series 9
2.2 WINDOWS DESKTOP/NOTEBOOK
This release supports the following data collection products for computers running Windows XP
Professional/Tablet PC (SP1, SP2, SP3):
•CompactFlash Mag Stripe Reader (MSR) Card Series 4
•CompactFlash Scan Card (CFSC) Series 5
April 8, 2010 Page 9
Document#: 6410-00147 K Revision 2.28

•Cordless Hand Scanner (CHS) Series 7
•Cordless Ring Scanner (CRS) Series 9
Full hot-swapping support is present for Windows 7, Vista, and XP.
Note: Use of a CompactFlash card in a Windows 7, Vista or XP based computer requires a
CF-to-PC Card adapter, available separately at:
http://ww1.socketmobile.com/products/handheld-computers/accessories-hc.aspx?cat=Plug-Ins
Starting from Desktop Release v3.7, SocketScan application support for Win 95, 98, Me and NT
platforms has been discontinued. Data collection products may run on these older devices, but
compatibility is no longer verified or guaranteed.
April 8, 2010 Page 10
Document#: 6410-00147 K Revision 2.28

3.0 USING SCANAPI
The ScanAPI SDK offers API calls that are grouped into the following categories:
The ScanAPI.DLL file is written in C++. This file can only be used in development environments that can
directly call Win32 DLLs and process Windows messages. At this time, there is no support for Java.
3.1 SDK INITIALIZATION/DE-INITIALIZATION
•ScanInit() initializes the ScanAPI DLL and allows the client to register for device insertion and
removal messages
•ScanEnableMultiScanner() enables multiple scanners
•ScanDeinit() closes any open scanning devices and performs clean-up in the DLL pending
shutdown
3.2 DEVICE CONTROL
•ScanOpenDevice() opens a scanning device for use
•ScanCloseDevice() closes a scanning device
•ScanGetDevInfo() returns a structure giving device identification and capabilities
•ScanSetGoodReadSound() allows the selection of a sound to be made when the user scans
data
•ScanGetStatus() returns current status of the scanner
•ScanParamSend() modifies a parameter of the scanner (CFSC/SDSC/CHS only)
•ScanParamRequest() retrieves a parameter of the scanner (CFSC/SDSC/CHS only)
•ScanParamSendEx() modifies a 2 byte parameter of the scanner (CFSC/SDSC/CHS only)
•ScanParamRequestEx() retrieves a 2 byte parameter of the scanner (CFSC/SDSC/CHS only)
•ScanSendCommand() sends a command to the CF Scan Card 5X (CF Scan Card 5X only)
•ScanCommandFeature() sends a specific command to use a scanner feature
3.3 SCANNER DATA ACCESS
•ScanRequestDataEvents() allows the client to register for scanned data notifications
•ScanTrigger() initiates a scan (soft-trigger) usually for a scanner with no hardware trigger
(CFSC/SDSC) or a Select Tag for the RFID reader and also works with the CHS/CRS
•ScanAbort() aborts a scan on a TAG read if one is in progress
•ScanGetScannerRegKey() returns the scanner’s active key or driver key
•ScanGetData() retrieves scanned data
3.4 MISCELLANEOUS UTILITY
•ScanErrToText() can be used to translate ScanAPI error codes to human-readable text
•IsScannerConntected() checks whether the scanner is connected and open for
communications
April 8, 2010 Page 11
Document#: 6410-00147 K Revision 2.28

•IsScannerConnectedEx() checks whether a specified scanner is connected
3.5 CORDLESS SCANNER SPECIFIC FUNCTIONS
•ScanEnableCHS() activates the Cordless Scanner (CS) and loads its driver
•ScanDisableCHS() deactivates the Cordless Scanner and unloads its driver
•ScanSendCmdtoCHS() sends the Cordless Scanner configuration commands
3.6 RFID SPECIFIC FUNCTIONS
•ScanRFIDSelectTag() selects one or more tags
•ScanRFIDReadTag() reads one or more data blocks from a tag
•ScanRFIDGetData() gets the response and data from a Select, Read, or Write tag command
•ScanRFIDWriteTag() writes one or more data blocks to a tag
•ScanRFIDLockTag() locks one or more blocks on a tag to prevent future writes
April 8, 2010 Page 12
Document#: 6410-00147 K Revision 2.28

4.0 SETTING UP THE TARGET DEVICE
Whether you are developing for Window CE or for Win32 Desktop systems, setting up the target device is
similar.
4.1 SETTING UP WINDOWS CE DEVICES
On the target CE device, the file ScanAPI.DLL must be present in the \Windows directory.
Additionally, you must copy one or more device driver files to the \Windows directory to support
the scanning device(s). See the Targeted Scanner Deployment documentation in this SDK for
specific information on adding the support files and registry entries for a particular scanner or
series of scanner to your target device.
If you install the SocketScan program onto your target CE device, all necessary API and driver files
will be installed and configured. SocketScan will run on the Microsoft Windows Mobile 2003 and
Windows CE platforms version 4.2 or higher. Before installing SocketScan, uninstall any previously
installed scanner software, including the “In-Hand Scanner” program (supplied with the initial
shipments of the CF Scan Card) on the target CE device. Also uninstall any legacy versions of the
Socket Wand Scanner programs from the target device, if present.
Installing SocketScan will install all the DLLs and set up the proper registry entries, but it should not
be used for installing the final user’s application program, because it can confuse the user with
unnecessary programs and Icons. The developer should follow the guidelines listed in this SDK
guide to can create an installer which will setup only the applications, drivers, and registry entries
needed to support the application.
*** It is recommended that SDK users determine exactly which DLLs and registry settings
are required for their application rather than using all SocketScan DLLs and settings ***
April 8, 2010 Page 13
Document#: 6410-00147 K Revision 2.28

5.0 WRITING YOUR APPLICATION
Applications that use ScanAPI must include the ScanAPI.h file in their project, and must either link to the
appropriate ScanAPI.lib file supplied with the SDK or manually load ScanAPI.dll and use GetProcAddress() to
access the functions. ScanAPI.h is located in the “inc” directory of the installed SDK. ScanAPI.lib is provided
for each supported processor and OS version in the “lib” directory of the installed SDK. The Win32-based
sample applications supplied in the SDK are configured with relative include and library paths to find these
files when recompiled.
Two windows messages must be defined within the WM_USER range defined by Windows. These messages
will be sent to the application when data collection devices are inserted or removed. This document
generically refers to these messages as wmInsertion (or WM_INSERTION) and wmRemoval (or
WM_REMOVAL). You must also choose a window that will service these messages, typically the main
window of your application. Use the window handle and the two messages as arguments to ScanInit(). You
must call ScanInit() before using any other ScanAPI function calls except for ScanEnableMultiScanner. Upon a
successful call to ScanInit(), your window will begin receiving WM_INSERTION and WM_REMOVAL messages,
as appropriate, when a data collection device is inserted or removed from the host device. You will receive a
WM_INSERTION immediately if a data collection device is present when the ScanInit() function call is made.
Note: If your application gets a SR_TOO_MANY_USERS error from ScanInit(), you may have ScktScan.exe
(keyboard wedge) or another ScanAPI client application running. You will need to close the program before
running your ScanAPI application program.
Message handlers must be written for your WM_INSERTION and WM_REMOVAL messages. The
WM_INSERTION handler should save the ScanAPI-assigned scanner handle (provided in lParam), then call
ScanOpenDevice() using the scanner handle. Upon success, you would use ScanGetDevInfo() if you are
interested in the type of scanner that was inserted, and optionally use ScanSetGoodReadSound() if you do
not like the default sound, which is to produce a MessageBeep(0) when a successful scan is completed. For
multiple devices ScanOpen()/ScanClose() should be called with the appropriate scanner handle.
The message handler for WM_REMOVAL should first check that the scanner handle returned in lParam is, in
fact, the handle of the scanner the application is currently aware of, then call ScanCloseDevice(). This release
of ScanAPI supports multiple scanners – in this case, multiple WM_INSERTION and WM_REMOVAL message
are seen, each with a different scanner handle supplied in lParam. If you do not require multiple scanners
there is no need to call ScanEnableMultiScanner(). If an application wants to ignore multiple scanners, it can
simply save the handle of the first scanner it sees in a WM_INSERTION message and ignore all other
WM_INSERTION messages.
Scanning applications will not be able to receive data until ScanRequestDataEvents() is called. A simple
scanning application will define a third windows message, which this document generically refers to as
wmScannerData (or WM_SCANNERDATA). This message is supplied along with the handle of the window
you want to process this message. The application’s handler for the WM_SCANNERDATA message will take
the scanner handle (supplied in lParam) and the size of the data (supplied in wParam), then call
ScanGetData(). The data retrieved can then be validated, pre-processed if desired, then sent to an edit
control, a list box, or dispatched in any manner the application desires.
A simple application would typically call ScanRequestDataEvents() as part of the WM_INSERTION message
handler. Since this registration is nullified whenever the scanning device is closed, it is necessary to call
ScanRequestDataEvents() again each time the scanner device is opened.
A more complex application may want to dynamically change the window that will process the
WM_SCANNERDATA message, and may even want to change the actual message to be received. This can be
done simply by calling ScanRequestDataEvents() again when you want the change to take effect. You can
April 8, 2010 Page 14
Document#: 6410-00147 K Revision 2.28

temporarily ignore all scanned data, if desired, by supplying NULL as the hWnd argument to
ScanRequestDataEvents().
When your application closes down, it should call ScanDeinit(). This function will close all open scanning
devices, making it unnecessary for you to call ScanCloseDevice() when you shut down.
All ScanAPI function calls return SR_SUCCESS if the function succeeds. If a failure occurs, the error returned
by the ScanAPI library can be translated to text using the ScanErrToText() function. This function translates
the error code into fairly technical jargon and, while this may be useful during software development, the
text may not be suitable for display in an end-user application. Since the error messages are located within a
string resource that is bound to the ScanAPI DLL file, you may change the wording of these error messages,
or translate the messages to different languages if desired, using a resource editing tool.
The Samples directory of the SDK contains several sample programs that can be found in the following
subdirectories:
5.1 PREVIEW DLL
This project demonstrates how to create a SocketScan Preview DLL.
5.2 RFID DEMO
This project demonstrates the usage of the RFID-specific API calls.
5.3 SCANAPITESTER
This project demonstrates the usage of the ScanAPI.
5.4 TRIGGERSAMPLE
This application demonstrates how to send a trigger message directly to the ScanAPI library.
5.5 CSHARP SAMPLE
A simple scanning application written using C#.
5.6 COMBO CARD CSHARP SAMPLE
A simple scanning application written using C# that demonstrates the multiple scanner support of
ScanAPI when using the CF RFID Reader-Scan Card 6M/6P.
5.7 RFID VB
This Visual Basic based application demonstrates the ScanAPI interfaces to the CF RFID Reader-Scan
Card 6M/6P.
5.8 VB SAMPLE
This application demonstrates ScanAPI access from Visual Basic.
April 8, 2010 Page 15
Document#: 6410-00147 K Revision 2.28

April 8, 2010 Page 16
Document#: 6410-00147 K Revision 2.28
ActivePairing and Permanent Pair features
The ActivePairing feature works only for Socket Bluetooth barcode scanners. When this feature is
activated, ScanAPI listens for an incoming connection from a Socket Bluetooth barcode scanner. The
device scans a special barcode which contains the Bluetooth address of the host computer and tries to
connect to the host.
If the ActivePairing feature cannot start, a wmInsertion message will be sent by ScanAPI with its wParam
set to 1. If this happens, the application should check for this wParam and will not need to open a device
if the wParam value is not 0.
In addition to the ActivePairing feature, a Permanent Pair feature can be used in order to have the
Socket Bluetooth barcode scanner automatically reconnect to the host computer each time the device is
powered on.
The Permanent Pair feature can be turned on by using the new Scanner property APIs
ScanOpenScannerProperty, ScanCloseScannerProperty, ScanGetScannerProperty and
ScanSetScannerProperty, described later in this document.
The property identifier for the Permanent Pair feature is SCAN_PROP_ID_PERMANENT_PAIR and it
accepts a DWORD value that can be 0 to disable Permanent Pair or 1 to enable it.
If a Socket Bluetooth barcode scanner connects to a host computer running ScanAPI that is configured
with Permanent Pair enabled, the device will then be permanently paired to this host. Each time the
device is powered on, it will try to reconnect to this host.
This permanent pair can be broken by several ways. The first way is to disable the Permanent Pair using
the new Scanner property APIs while the device is connected. The second way is to scan a special barcode
with the device to reset its operational mode back into acceptor mode. In acceptor mode, the device
doesn’t try to connect to any host but instead waits for a host to connect.

6.0 SOFT TRIGGERING
Soft triggering differs from local and remote triggering options. It is a means to trigger a scan on a scanner
through software; however, this feature is not applicable to all scanners. It is supported in the CFSC, SDSC,
CHS, CRS and CF RFID Reader Card. Soft-triggering is enabled within your application via a function key or a
button that, when clicked, calls the ScanTrigger() function.
Depending on how your application is designed, some developers may want to assign a hardware button on
the host CE device as the trigger, or a function key on Win32 Desktop systems as the trigger, but find it
necessary to have this mechanism separate from the application that is directly using the ScanAPI. Since only
one executable is allowed to use the ScanAPI at any given time, one way to accomplish this is to write a
custom message handler in your application that will handle a WM_SCAN message that you define. The
message handler for this WM_SCAN message will call ScanTrigger(). You can then write a very small
application that you can assign to one of the hardware buttons on the CE device, or a similar application for
the Win32 Desktop environment that hooks the keyboard to detect function key presses. This application
should do a FindWindow() to find your application’s main window and send that window your WM_SCAN
message.
There is a sample triggering application available in the Utils directory of the SDK. This sample takes the
handle of the scanner as a parameter to the executable and can be used to trigger any scanner. It will also
work with a .NET application since it sends the message directly to ScanAPI.
The SocketTriggerScan and SocketTriggerRFID applications effectively function as the sample Trigger
application with the appropriate preferred handle passed in. Refer to Chapter 13 for more details.
NOTE: SocketTriggerSelect is only used with Socketscan.exe
April 8, 2010 Page 17
Document#: 6410-00147 K Revision 2.28

7.0 SCANAPI TYPE REFERENCE
The following excerpts are taken from ScanAPI.h. The brief explanations that follow the excerpts further
document the purpose of the identifiers. Refer to the RFID SDK documentation for RFID-specific information.
// Types of Socket Scanner products
enum SCANNER_TYPE {SCANNER_NONE = 0, // no scanner
SCANNER_CFCARD, // a CF Scan Card 5E/5M/5P
SCANNER_CHS, // a CHS (Cordless Hand Scanner)
SCANNER_SDIO, // an SD Scan Card
SCANNER_RFID, // an RFID scanner
SCANNER_MAG_STRIPE, // a Magnetic Stripe Reader
SCANNER_CRS, // a CRS (Cordless Ring Scanner)
SCANNER_CF5X // a CF Scan Card 5X
};
SCANNER_TYPE is a value that is filled into the ScannerType field of the SCANDEVINFO structure (defined
below.) By checking this value, you can determine whether the user has inserted a CF Scan Card, Cordless
Hand Scanner, CF RFID Reader Card, etc.
// Types of good-read sounds
enum GRS_TYPE {GRS_NONE = 0, // no good read sound
GRS_MESSAGEBEEP, // play MessageBeep(0) on good read
GRS_WAVFILE}; // play user-supplied .WAV file on good read
A GRS_TYPE variable is used as an argument when making a call to ScanSetGoodReadSound().
// Scanner device information structure
typedef struct tagSCANDEVINFO{
DWORD StructSize; // size of the structure
SCANNER_TYPE ScannerType; // integrated card
unsigned int fSoftwareTrigger :1; // most likely an integrated card
unsigned int fSoftwareAbortTrigger :1; // most likely an integrated card
THCAR SymbolType; // the symbol type (UPC, Code 128, etc.) for last scan
} SCANDEVINFO, *LPSCANDEVINFO;
The SCANDEVINFO structure is filled in when it is used in a call to ScanGetDevInfo(). You must fill in the size
of the structure, using sizeof(SCANDEVINFO) before calling ScanGetDevInfo(), or an error will result. The rest
of the fields have the following meanings:
ScannerType is as defined above.
fHardwareTrigger will be TRUE if the device has its own hardware trigger
fSoftwareTrigger will be TRUE if calling ScanTrigger() can trigger a scan on the device
fSoftwareAbortTrigger will be TRUE if calling ScanAbort() can abort a scan in progress
fGoodReadLight will be TRUE if the device has a visual good-read indicator on-board
fGoodReadSound will be TRUE if the device makes a sound when data is successfully scanned
SymbolType is the code for the last bar code symbol scanned. The value is only valid for the CFSC, SDSC, and
CHS, and will be 0x00 if the symbol type is not available. This field is updated when ScanGetData() is called.
For a list of bar code values, please refer to the SocketScan Advanced Programming Guide, available online
at: www.socketmobile.com/pdf/data-collection/iscprog.pdf
April 8, 2010 Page 18
Document#: 6410-00147 K Revision 2.28

// API return codes
enum SCAN_RESULT {SR_SUCCESS = 0,
SR_INVALID_WMINSERTION,
SR_INVALID_WMREMOVAL,
SR_PLUG_THREAD_FAILURE,
SR_DEVICE_THREAD_FAILURE,
SR_INVALID_SCANNER_HANDLE,
SR_OPEN_FAILURE,
SR_INVALID_WMSCANNERDATA,
SR_NO_DATA,
SR_BUFFER_TOO_SMALL,
SR_SCANNER_NOT_OPEN,
SR_INVALID_SOUND_TYPE,
SR_WAVFILE_NOT_FOUND,
SR_MEMORY_FAILURE,
SR_INVALID_ERR,
SR_TOO_MANY_USERS,
SR_NOT_INITIALIZED,
SR_DEVICE_FAILURE,
SR_INTERNAL_FAILURE,
SR_INVALID_STRUCTURE,
SR_SCANNER_REMOVED,
SR_UNSUPPORTED_FEATURE,
SR_INVALID_WMCHSSTATUS,
SR_NOT_CHS_DEVICE,
SR_WAIT_TIMEOUT_ERROR,
SR_SYMBOLOGY_NOT_SUPPORTED,
SR_SCANNER_BUSY,
SR_HOTSWAP_ERROR, (Windows XP ONLY)
SR_SCANNER_REMOVED,
SR_INVALID_WMCHSSTATUS,
SR_NOT_CHS_DEVICE,
SR_WAIT_TIMEOUT_ERROR,
SR_SYMBOLOGY_NOT_SUPPORTED,
SR_SCANNER_BUSY,
SR_INVALID_WMDIRECTSTATUS
SR_INCOMPATIBLE_VERSION,
SR_INVALID_PARAMETERS,
SR_NO_ACTIVEPAIRING};
All ScanAPI function calls return SR_SUCCESS if the call was successful. If an error occurs, the return value will
be one of the other defined error codes.
Note that SR_HOTSWAP_ERROR is defined in the Win32 Desktop header file only and
SR_SCANNER_REMOVED is defined in the WinCE header file only.
Also note that several of the return codes are classified as “failures”:
SR_PLUG_THREAD_FAILURE
SR_DEVICE_THREAD_FAILURE
SR_OPEN_FAILURE
SR_MEMORY_FAILURE
SR_DEVICE_FAILURE
April 8, 2010 Page 19
Document#: 6410-00147 K Revision 2.28

SR_INTERNAL_FAILURE
If you receive one of these return codes, it means something has gone wrong internally in the ScanAPI DLL,
the scanning device has experienced a failure (or unexpected removal), or there are too few resources
available on the host device to carry out the request. Any of the first 4 failures listed above may be
correctable if the user is asked to close other programs that may be running on the device, thereby freeing
up additional resources. A condition that causes SR_DEVICE_FAILURE may be correctable if the user removes
the scanner from the device and re-starts your application. SR_INTERNAL_FAILURE is a catch-all for unknown
failures that may occur in the ScanAPI DLL. Again, it may be correctable by taking one of the actions already
mentioned.
Receiving one of these return codes should be extremely rare. If one of the suggested courses of action does
not correct the error condition, the user may be forced to remove the scanner from the CE device and
perform a soft reset, or restart the system if the failure has occurred on a Win32 Desktop platform. Please
report to Socket Technical Support at http://support.socketmobile.com/
if you consistently receive one of these errors for no good reason – you may be trying to use the API in ways
we did not envision when we created it.
April 8, 2010 Page 20
Document#: 6410-00147 K Revision 2.28
Table of contents
Other Socket Software manuals
Popular Software manuals by other brands

Xerox
Xerox WorkCentre M118 Getting started guide

Juniper
Juniper SECURITY THREAT RESPONSE MANAGER - LOG MANAGEMENT INSTALLATION REV... installation guide

Z3 Technology
Z3 Technology Z3-DM8169-APP-L1-RPS user guide

McAfee
McAfee AVM85M - VirusScan For Mac user guide

Novell
Novell PLATESPIN ORCHESTRATE 2.0.2 - ADMINISTRATOR REFERENCE... Reference

McAfee
McAfee VIRUSSCAN 5.1 Administrator's guide