bardecode.com
barcode reading software
  • Home
  • Download
  • Purchase
  • SDK Licensing
  • Pricing
    • Windows SDK Price List
    • Windows SDK with PDF Extension Price List
    • Linux SDK Price List
    • Linux SDK with PDF Extension Price List
    • PDF Extension For Windows Price List
    • Multi-Platform Toolkit for .NET Price List
    • BardecodeFiler Desktop Only Price List
    • BardecodeFiler Windows Service Price List
    • DOS Command Prompt Barcode Tool Price List
    • Terms and Conditions
    • Refund Policy
  • Products
    • Softek Barcode Reader Toolkit for Windows
    • Softek Barcode Reader Toolkit for Linux
    • BardecodeFiler Desktop App
    • BardecodeFiler Windows Service
    • Windows DOS Command Prompt Tool
    • Multi-platform barcode reader toolkit for .NET
    • Aquaforest’s Autobahn DX
  • Knowledge Base
    • Documentation
    • Specifications
  • News
  • Contact
    • About Us
    • Terms and Conditions
    • Resellers
    • Links
Select Page ...

News

Reading Barcodes with Delphi using win32 dll

admin November 27, 2012 Software Development Kits No Comments

Using the Softek Barcode Reader SDK with Delphi is pretty straight forward and we include a full example project with our download. This page aims to get you up and running in less than 15 minutes…

Note that this example uses the win32 DLL interface to the SDK – if you would rather use the COM interface then click here.

Step 1.

Download the barcode reader sdk from here

Step 2.

Now at this point you can either use the ready made project at the following location:

<installation folder>\Projects\Delphi using win32 dll\Project1.dpr

Or, if you just want to get it working in your application ASAP then copy…

<installation folder>\Projects\Delphi using win32 dll\Softekbarcode.pas

…into your working folder and add it your project (right click on your project in the Project Manager and select Add and browse for the Softekbarcode.pas file)

 


Step 4.

Open your PAS file (e.g Unit1.pas) and add SoftekBarcode to the “uses” section.

e.g:

 

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, SoftekBarcode;

 

Step 5:

Declare a variable called hBarcode of type Pointer. This will be our handle to the barcode library. You wil also need to declare some other variables for the example code below:

var
	hBarcode: Pointer;
	i: Integer;
	barcodeValue: String;
	nBarCodes: Integer;

 

Step 6:

In the procedure where you want to read the barcodes add the following code:

if (InitSoftekLibrary('\path\to\sdk\x86\softekbarcode.dll') = false) then
	exit;
hBarcode:=mtCreateBarcodeInstance;
mtSetMultipleRead(hBarcode, true);
nBarCodes := mtScanBarcode(hBarcode, pAnsiChar(UTF8String('someimage.tif')));
if (nBarcodes > 0) then
begin
	for i := 1 to nBarcodes do
	begin
 		barcodeValue := System.Utf8ToUnicodeString(mtGetBarString(hBarcode, i));
	end;
end;
mtDestroyBarcodeInstance(hBarcode);

Where \path\to\sdk\x86\softekbarcode.dll is the path to the location of the softekbarcode.dll file. Note that this might need to be the x64 version on some systems. The InitSoftekLibrary function only needs to be called once, so it would be better to place it in the FormCreate procedure.

Step 7:

That’s it – all done. But don’t forget that there is a lot more to the sdk than just this. If you have any questions then please contactsupport@bardecode.com .

You also might wish to add some extra lines of code to turn on or off various barcode types and maybe set a license key:

mtSetReadQrCode(hBarcode, true);
mtSetLicenseKey(hBarcode, pAnsiChar(UTF8String('MY LICENSE KEY')));
← Reading Barcodes with Delphi using com
Reading Barcodes in VB.Net →
admin

  • Copyright © 2023 Softek Software Ltd. All Rights Reserved