{"id":651,"date":"2012-11-27T16:01:37","date_gmt":"2012-11-27T16:01:37","guid":{"rendered":"http:\/\/www.bardecode.com\/en1\/?p=651"},"modified":"2013-02-19T11:00:31","modified_gmt":"2013-02-19T11:00:31","slug":"reading-barcodes-with-delphi-using-com","status":"publish","type":"post","link":"https:\/\/www.bardecode.com\/en1\/reading-barcodes-with-delphi-using-com\/","title":{"rendered":"Reading Barcodes with Delphi using com"},"content":{"rendered":"<p>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&#8230;<\/p>\n<p>Note that this example uses the COM interface to the SDK. If you would rather use the win32 DLL interface then\u00a0<a href=\"http:\/\/bardecode.com\/en\/knowledge-base\/268-reading-barcodes-with-delphi.html\">click here<\/a>.<\/p>\n<h1>Step 1.<\/h1>\n<p>Download the barcode reader sdk from\u00a0<a href=\"http:\/\/www.bardecode.com\/barcoder.exe\">here<\/a><\/p>\n<h1>Step 2.<\/h1>\n<p>Navigate to where the sdk was installed and open the x86 folder, right click on REGISTER.BAT and select &#8220;Run as Administrator&#8221;. This will run regsvr32 on SoftekATL.dll &#8211; which is the dll you will be using later on.<\/p>\n<h1>Step 3.<\/h1>\n<p>Open Delphi and start a new forms project or open the one you want to use for barcode reading.<\/p>\n<p>Click on Component followed by Import Component to start the &#8220;Import Component Wizard&#8221;&#8230;<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/bardecode.com\/images\/delphi1.png\" alt=\"\" border=\"0\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Click on Next to &#8220;Import a Type Library&#8221;<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/bardecode.com\/images\/delphi2.png\" alt=\"\" border=\"0\" \/><\/p>\n<p>Scroll down to and click on &#8220;SoftekATL X.X.X Type Library&#8221;<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/bardecode.com\/images\/delphi3.png\" alt=\"\" border=\"0\" \/><\/p>\n<p>Then click through the rest of the wizard taking the defaults.<\/p>\n<p>&nbsp;<\/p>\n<h1>Step 4.<\/h1>\n<p>Open your PAS file (e.g Unit1.pas) and add SoftekATL_TLB to the &#8220;uses&#8221; section.<\/p>\n<p>e.g:<\/p>\n<p>&nbsp;<\/p>\n<pre>uses\r\n\u00a0 Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,\r\n\u00a0 Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, SoftekATL_TLB;<\/pre>\n<p>&nbsp;<\/p>\n<h1>Step 5:<\/h1>\n<p>Declare a variable called oBarcode of type CBarcode and some other variables for the example code below:<\/p>\n<pre>var\r\n\toBarcode: CBarcode;\r\n\ti: Integer;\r\n\tbarcodeValue: String;\r\n\tnBarCodes: Integer;<\/pre>\n<p>&nbsp;<\/p>\n<h1>Step 6:<\/h1>\n<p>In the procedure where you want to read the barcodes add the following code:<\/p>\n<pre>oBarcode := CoCBarcode.Create;\r\noBarcode.MultipleRead := 1;\r\noBarcode.ScanBarcode('someimage.tif');\r\nnBarCodes := oBarcode.BarCodeCount;\r\nif (nBarcodes &gt; 0) then\r\nbegin\r\n\tfor i := 1 to nBarcodes do\r\n\tbegin\r\n \t\tbarcodeValue :=\u00a0oBarcode.BarString[i];\r\n\tend;\r\nend;<\/pre>\n<p>&nbsp;<\/p>\n<h1>Step 7:<\/h1>\n<p>That&#8217;s it &#8211; all done. But don&#8217;t forget that there is a lot more to the sdk than just this. If you have any questions then please contact<a href=\"mailto:support@bardecode.com\">support@bardecode.com<\/a>\u00a0.<\/p>\n<p>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:<\/p>\n<pre>oBarcode.ReadQrCode := 1;\r\noBarcode.LicenseKey := 'MY LICENSE KEY';<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230; Note that this example uses the COM interface to the SDK. If you would rather use the win32 DLL<\/p>\n<p><a href=\"https:\/\/www.bardecode.com\/en1\/reading-barcodes-with-delphi-using-com\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":320,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[76,31],"tags":[19,47,180,179,181,65],"class_list":["post-651","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-settings","category-software-development-kits","tag-barcode","tag-delphi","tag-demo","tag-download","tag-free","tag-sdk-2"],"_links":{"self":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/651"}],"collection":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/comments?post=651"}],"version-history":[{"count":3,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/651\/revisions"}],"predecessor-version":[{"id":653,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/651\/revisions\/653"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/media\/320"}],"wp:attachment":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/media?parent=651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/categories?post=651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/tags?post=651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}