[Visual Basic]
'Create a new instance of Barcode Decoder object
Dim dec As Object
Set dec = CreateObject("BarcodeReader.BarcodeDecoder")
dec.BarcodeTypes = &H1 Or &H8 Or &H80 'only Code128, EAN13 and UPCA
dec.ShowImage = False
dec.LinearFindBarcodes = 7
'decode file
dec.DecodeFile ("c:\barcodes.jpg")
'show results
For i = 0 To dec.Barcodes.length - 1
Dim bc As Barcode
Set bc = dec.Barcodes.Item(i)
txt = ""
If bc.BarcodeType = Codabar Then txt = txt & "Codabar"
If bc.BarcodeType = Code11 Then txt = txt & "Code11"
If bc.BarcodeType = Code128 Then txt = txt & "Code128"
If bc.BarcodeType = Code39 Then txt = txt & "Code39"
If bc.BarcodeType = EAN13 Then txt = txt & "EAN13"
If bc.BarcodeType = EAN8 Then txt = txt & "EAN8"
If bc.BarcodeType = Interl25 Then txt = txt & "Interl25"
If bc.BarcodeType = UPCA Then txt = txt & "UPCA"
If bc.BarcodeType = UPCE Then txt = txt & "UPCE"
txt = txt & ": " & bc.Text
txt = txt & " (" & bc.X1 & "," & bc.Y1 & ")," & "(" & bc.X2 & "," & _
bc.Y2 & ")," & "(" & bc.x3 & "," & bc.y3 & ")," & "(" & bc.x4 & _
"," & bc.y4 & ")"
MsgBox txt
Next i
Set dec = Nothing
[C/C++]
#include <crtdbg.h>
#include <atlcomcli.h>
#import "progid:BarcodeReader.BarcodeDecoder" no_namespace
int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr = ::CoInitialize( NULL );
_ASSERTE( SUCCEEDED(hr) );
CComPtr<IBarcodeDecoder> pIBarcodeDecoder;
hr = pIBarcodeDecoder.CoCreateInstance( __uuidof(BarcodeDecoder) );
_ASSERT( SUCCEEDED(hr) );
pIBarcodeDecoder->put_LinearFindBarcodes( 7 );
hr = pIBarcodeDecoder->DecodeFile( "c:\\barcodes.jpg" );
_ASSERTE( SUCCEEDED(hr) );
CComPtr<IBarcodeList> pIBarcodeList;
hr = pIBarcodeDecoder->get_Barcodes( &pIBarcodeList );
_ASSERTE( pIBarcodeList );
long len;
hr = pIBarcodeList->get_length( &len );
_ASSERTE( pIBarcodeList );
for( long i=0; i < len; ++i )
{
CComPtr<IBarcode> pBarcode;
pBarcode = pIBarcodeList->item( i );
_ASSERTE( pBarcode );
printf( "%s\n", (LPCTSTR)pBarcode->Text );
}
return 0;
}