-
2
USI.DLL – Unitech Scanner Interface DLL
2.1 Register the application to the USI DLL
Function Description:
Register the application to the USI DLL, so that the DLL can communicate with the application. It
will also open and initial scanner port (COM2, for example) and set the scanner to the working
mode. The application should call USI_Unregister to unregister from the DLL after done with the
scanner.
Function call:
BOOL
USI_Register
(
HWND
hwnd
,
UINT
msgID
);
Parameter: (input)
hwnd: Handle of the window to which USI DLL will send messages to report all
activities, including error messages, scan data ready, etc.
msgID
:
Specifies the message to be posted. DLL will post messages by calling:
PostMessage(hwnd, msgID, msg, param).
The window procedure will receive custom message about msgID and wParam parameter
can be one of the followings:
SM_ERROR_SYS:
Indicates a system error, which is caused by a call to the system
function. Param contains the error code from GetLastEror().
SM_ERROR
Indicates an error. Param contains the cause of error, which can
be on of followings:
SERR_INVALID_HWND
: Invalid
window
handle.
SERR_INVALID_MSGID
:
msgID cannot be 0.
SERR_OPEN_SCANNER
:
Open or initial scanner port failed.
SERR_CHECKSUM
:
Checksum error in received packet.
SERR_DATALOST
:
New scan data is lost because data
buffer is not empty.
SERR_BUFFEROVERFLOW
:
Data buffer overflow. The default size
is 4K bytes.
SM_REPLY
Indicates received a reply. All the responses from the scanner
except the scan data will be notified by this message.
SM_DATAREADY
Indicates that scan data is successfully decoded and ready to
retrieve.
SM_ACK
Indicates received a ACK.
SM_NAK
Indicates received a NAK.
SM_NOREAD
Indicates received a No-Read packet.
Note: Scanner port settings are defined in registry as described below:
[HKEY_LOCAL_MACHINE\SOFTWARE\Unitech America Inc.\Scanner\Settings]
"COMPORT"="COM2:"
"BAUDRATE"="38400"
"STOPBITS"="1"
"PARITY"="None"