6 - 2
Barcode Capture
Sample 3 - A synchronous barcode capture
HHP_DECODE_MSG decodeInfo;
TCHAR tcErrMsg[ 128 ]; // Error message buffer.
Result_t nResult = RESULT_ERR_INTIALIZE; // Return code.
// Make sure to set the structure size!
decodeInfo.dwStructSize = sizeof( HHP_DECODE_MSG );
// Call the SDK function to capture a barcode setting the bWait parameter to TRUE, 6
second timeout.
if ( (nResult = hhpCaptureBarcode( &decodeInfo,6000,TRUE ) == RESULT_SUCCESS )
{
_tprintf( _T(“Barcode: %s\n”),decodeInfo.pchMessage );
_tprintf( _T(“Barcode Length: %d\n”),decodeInfo.nLength );
_tprintf( _T(“AIM Id : %cn”),decodeInfo.chCodeID );
_tprintf( _T(“HHP Id: %cn”),decodeInfo.chSymLetter );
_tprintf( _T(“Symbol Modifier: %c\n”),decodeInfo.chSymModifier );
}
else
{
hhpGetErrorMessage( nResult,tcErrMsg );
_tprintf( _T(“Capture Barcode Returned: %s\n”),tcErrMsg );
}
Sample 4 - An asynchronous barcode capture using an event
HHP_DECODE_MSG decodeInfo; // Returned decoded data message
structure.
hhpEventType_t eventType = HHP_BARCODE_EVENT; // Type of event that occurred.
TCHAR tcErrMsg[ 128 ]; // Error message buffer.
Result_t nResult = RESULT_ERR_INTIALIZE; // Return code.
// Verify the event is valid (or you won’t get any notification)
If( hEvent != NULL )
{
// Register the event with the SDK.
if ( (nResult = hhpSetAsyncMethods( hEvent,NULL,NULL ) == RESULT_SUCCESS )
{
// Call the SDK function to capture a barcode setting the bWait parameter to FALSE,
6 second timeout.
if ( (nResult = hhpCaptureBarcode( NULL,6000,FALSE ) == RESULT_SUCCESS )
{
// Make sure to set the structure size!
decodeInfo.dwStructSize = sizeof( HHP_DECODE_MSG );
// Wait on event being set by SDK then call SDK to get results.
if( WaitForSingleObject( hEvent,7000 ) == WAIT_OBJECT_0 )
nResult = hhpGetAsyncResult( &event,&decodeInfo );
}
}
}
if( nResult == RESULT_SUCCESS )
{
_tprintf( _T(“Barcode: %s\n”),decodeInfo.pchMessage );
_tprintf( _T(“Barcode Length: %d\n”),decodeInfo.nLength );
_tprintf( _T(“AIM Id : %cn”),decodeInfo.chCodeID );
_tprintf( _T(“HHP Id: %cn”),decodeInfo.chSymLetter );
_tprintf( _T(“Symbol Modifier: %c\n”),decodeInfo.chSymModifier );