{"id":1960,"date":"2014-10-16T09:31:53","date_gmt":"2014-10-16T09:31:53","guid":{"rendered":"http:\/\/www.bardecode.com\/newsite\/?p=1960"},"modified":"2019-04-05T09:35:22","modified_gmt":"2019-04-05T09:35:22","slug":"using-the-softekbarcode-dll-with-python","status":"publish","type":"post","link":"https:\/\/www.bardecode.com\/newsite\/using-the-softekbarcode-dll-with-python\/","title":{"rendered":"Using the SoftekBarcode DLL with Python"},"content":{"rendered":"<p>The following code as been kindly contributed by a developer to show how to use the SoftekBarcode DLL interface with Python:<\/p>\n<p><code><br \/>\nPython 3.7:<\/p>\n<p>import ctypes<br \/>\nfrom ctypes import *<br \/>\nimport os<\/p>\n<p># Load the dll<br \/>\nsoftekDLL = ctypes.OleDLL(\"C:\\\\tmp\\\\SoftekBarcodedll.dll\")<\/p>\n<p># Create Barcode Instance and Set License Key<br \/>\nbarCode1 = softekDLL.mtCreateBarcodeInstance()<\/p>\n<p># Set the license key<br \/>\nsoftekDLL.mtSetLicenseKey(barCode1, 'your license key'.encode('utf-8'))<\/p>\n<p># Scan some file<br \/>\nn = softekDLL.mtScanBarCode(barCode1,'\\\\path\\\\to\\\\some\\\\file.jpg'.encode('utf-8'))<\/p>\n<p># print the barcode<br \/>\nprint (ctypes.c_char_p(softekDLL.mtGetBarString(barCode1,1)).value)<br \/>\n<\/code><\/p>\n<p>Python 2.7:<\/p>\n<p>import ctypes<br \/>\nfrom ctypes import *<br \/>\nimport os<\/p>\n<p># Set up the path to SoftekBarcode.dll<br \/>\nsoftek = r&#8217;C:\\\\Your\\\\Path\\\\To\\\\softek_barcode_sdk\\\\x86&#8242;<br \/>\nos.environ[&#8216;PATH&#8217;] = &#8216;;&#8217;.join([softek, os.environ[&#8216;PATH&#8217;]])<br \/>\nsoftekDLL = ctypes.OleDLL(os.path.join(softek, &#8216;SoftekBarcode.dll&#8217;))<\/p>\n<p># Create Barcode Instance and Set License Key<br \/>\nbarCode1 = softekDLL.mtCreateBarcodeInstance()<br \/>\nsoftekDLL.mtSetLicenseKey(barCode1,&#8217;Your License Key&#8217;)<\/p>\n<p># Configure Scanner for DataMatrix w\/Skew<br \/>\nsoftekDLL.mtSetReadDataMatrix(barCode1,True)<br \/>\nsoftekDLL.mtSetSkewedDatamatrix(barCode1,True)<br \/>\nsoftekDLL.mtSetSkewTolerance(barCode1,1)<\/p>\n<p># Scan a code and report on the findings<br \/>\n# c_char_p() effectively casts the result to a char string<br \/>\nn = softekDLL.mtScanBarCode(barCode1,&#8217;C:\\\\Your\\\\Path\\\\To\\\\DSCN3724.JPG&#8217;)<br \/>\nprint &#8220;%s %s Found&#8221; % (n,c_char_p(softekDLL.mtGetBarStringType(barCode1,1)).value)<br \/>\nprint c_char_p(softekDLL.mtGetBarString(barCode1,1)).value<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following code as been kindly contributed by a developer to show how to use the SoftekBarcode DLL interface with Python: Python 3.7: import ctypes from ctypes import * import os # Load the dll softekDLL = ctypes.OleDLL(&#8220;C:\\\\tmp\\\\SoftekBarcodedll.dll&#8221;) # Create Barcode Instance and Set License Key barCode1 = softekDLL.mtCreateBarcodeInstance() # Set the license key softekDLL.mtSetLicenseKey(barCode1, &hellip; <\/p>\n","protected":false},"author":1,"featured_media":326,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[217,18,203,31],"tags":[],"class_list":["post-1960","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","category-knowledge-base","category-news","category-software-development-kits"],"_links":{"self":[{"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/posts\/1960"}],"collection":[{"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/comments?post=1960"}],"version-history":[{"count":3,"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/posts\/1960\/revisions"}],"predecessor-version":[{"id":2466,"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/posts\/1960\/revisions\/2466"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/media\/326"}],"wp:attachment":[{"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/media?parent=1960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/categories?post=1960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bardecode.com\/newsite\/wp-json\/wp\/v2\/tags?post=1960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}