Plain DLL Version of StrokeScribe Barcode Generator

The plain DLL version of StrokeScribe barcode generator allows to dynamically load the generator without ActiveX registration.

This version offers the same functionality as the ActiveX-based barcode generator, but can be loaded from programs that do not support OLE.

The installer contains both ActiveX and DLL versions of the barcode generator.

Properties and Methods

Initialize

Initializes the barcoding library.

You need to initialize the library before you call any other DLL functions.

Syntax

Parameters:

This function has no parameters.

Return value

Remarks

Developer license users could find more information in the Developer zone.

Example

Dim rc As Long rc = Initialize() If rc <> 0 Then Debug.Print "Initialize() failed, error code = " & rc End If

GetVer

Returns the library version numbers.

Syntax

Parameters:

Return value

Example

Dim rc As Long Dim verMajor, verMajor2, verMinor As Long rc = GetVer verMajor, verMajor2, verMinor If rc <> 0 Then Debug.Print "GetVer() failed, error code = " & rc else Debug.Print "DLL version: " & verMajor & "." & verMajor2 & "." & verMinor End If

SetLongPropU/SetLongPropA

Sets the value of a numeric property of the barcode generator.

Syntax

Parameters:

Return value

Examples

Choosing a barcode type:

rc = SetLongPropU StrPtr("Alphabet"), 5 ' 5 = CODE128 If rc <> 0 Then Debug.Print "SetLongPropU() failed, error code = " & rc End If

Encoding data in UTF-8:

rc = SetLongPropU StrPtr("CodePage"), 65001 ' UTF-8 If rc <> 0 Then Debug.Print "SetLongPropU() failed, error code = " & rc End If

Remarks

The list of properties that can be modified through the SetLongPropU (DLL version of the barcode generator shares property names with the ActiveX):

SetTextPropU/SetTextPropA

Sets the value of a text property.

Syntax

Parameters:

Return value

Examples

Encoding a text string in the barcode:

Dim text As String text = "ABCDE3457" rc = SetTextPropU(StrPtr("Text"), StrPtr(text)) If rc > 0 Then Debug.Print "SetTextPropU() failed, error code: " & rc Exit Sub End If

Modifying the text below the barcode:

rc = SetTextPropU(StrPtr("TextBelow"), StrPtr("Some text")) If rc > 0 Then Debug.Print "SetTextPropU() failed, error code: " & rc Exit Sub End If

Remarks

The list of properties that can be modified through the SetTextPropU (DLL version of the barcode generator shares property names with the ActiveX):

SetVariantPropU

Sets the value of a VARIANT property.

Use this function to pass byte arrays to the barcode generator.

Syntax

Parameters:

Return value

Example

How to encode a byte array in QR Code and put the barcode into a BMP file:

Private Sub Test_F() Dim rc As Long rc = Initialize() If rc <> 0 Then Debug.Print "Initialize() failed, error code = " & rc Exit Sub End If SetLongPropU StrPtr("Alphabet"), 25 'QRCODE SetLongPropU StrPtr("CodePage"), -1 'Raw binary data, code page translation is disabled Dim arr(4) As Byte arr(0) = 1 arr(1) = 2 arr(2) = 3 arr(3) = 4 rc = SetVariantPropU(StrPtr("Text"), arr) If rc > 0 Then Debug.Print "SetVariantPropU() failed, error code: " & rc Exit Sub End If Dim w, h As Long GetLongPropU StrPtr("BITMAPW"), w GetLongPropU StrPtr("BITMAPH"), h Dim pic_path As String pic_path = Environ("TEMP") & "\bar.bmp" rc = SavePictureU(StrPtr(pic_path), 0, w * 10, w * 10, 0) If rc > 0 Then Debug.Print "SavePicture() failed, error code: " & rc Exit Sub End If Shell "explorer.exe " & pic_path End Sub

Remarks

The list of properties that can be modified through the SetVariantPropU (DLL version of the barcode generator shares property names with the ActiveX):

SetDoublePropU

Sets the value of a floating-point property.

Syntax

Parameters:

Return value

Example

Dim rc As Long rc = SetDoublePropU(StrPtr("PDF417SymbolAspectRatio"), 0.1) If rc > 0 Then Debug.Print "SetDoublePropU() failed, error code: " & rc Exit Sub End If

Remarks

The list of properties that can be modified through the SetDoublePropU (DLL version of the barcode generator shares property names with the ActiveX):

GetLongPropU/GetLongPropA

Retrieves the value associated with the specified property name.

Syntax

Parameters:

Return value

Example

Dim rc As Long Dim w As Long rc = GetLongPropU(StrPtr("BITMAPW"), w) If rc > 0 Then Debug.Print "GetLongPropU() failed, error code: " & rc Else Debug.Print "Bitmap width: " & w End If

Remarks

The list of properties that can be modified through the GetLongPropU (DLL version of the barcode generator shares property names with the ActiveX):

SavePictureU/SavePictureA

The function saves the barcode image into a file.

This is the same function as the SavePicture in the ActiveX/Class. For more information, see the ActiveX documentation.

Syntax

Parameters:

Return value

Remarks

The function provides limited functionality in free version of the barcode generator.

Example

Private Sub Test() Dim rc As Long rc = Initialize() If rc <> 0 Then Debug.Print "Initialize() failed, error code = " & rc Exit Sub End If SetLongPropU StrPtr("Alphabet"), 25 'QRCODE SetLongPropU StrPtr("CodePage"), 65001 'UTF-8 SetLongPropU StrPtr("QrECL"), 2 Dim text As String text = "ABCDE3457" rc = SetTextPropU(StrPtr("Text"), StrPtr(text)) If rc > 0 Then Debug.Print "SetTextProp() failed, error code: " & rc Exit Sub End If Dim w, h As Long rc = GetLongPropU(StrPtr("BITMAPW"), w) ' For square barcodes (QR, DataMatrix), these properties contain the same value (for example, 24x24) rc = GetLongPropU(StrPtr("BITMAPH"), h) Dim pic_path As String pic_path = Environ("TEMP") & "\bar.bmp" rc = SavePictureU(StrPtr(pic_path), 0, w * 4, h * 4, 0) '4x4-pixel barcode modules If rc > 0 Then Debug.Print "SavePicture() failed, error code: " & rc Exit Sub End If Shell "explorer.exe " & pic_path End Sub

GetPictureArray

The function saves the barcode image into a byte array.

This is the same function as the GetPictureArray in the ActiveX/Class. For more information, see the ActiveX documentation.

Syntax

Parameters:

Return value

Remarks

The function provides limited functionality in free version of the barcode generator.

Requirements

Example

Private Sub Test() Dim rc As Long rc = Initialize() ' Initializing the library If rc <> 0 Then Debug.Print "Initialize() failed, error code = " & rc Exit Sub End If ' Producing a CODE 128 barcode SetLongPropU StrPtr("Alphabet"), 5 '=CODE128 Dim text As String text = "1234ABC" rc = SetTextPropU(StrPtr("Text"), StrPtr(text)) ' Encoding the text string in the barcode If rc > 0 Then Debug.Print "SetTextPropU() failed, error code: " & rc Exit Sub End If Dim w As Long GetLongPropU StrPtr("BITMAPW"), w ' The call returns the minimum bitmap size that fits the barcode Dim v As Variant ' This will store the byte array of the barcode picture rc = GetPictureArray(v, 0, w * 4, w * 2, 0) ' Bar width = 4 pixel, barcode height = 1/2 of the width If rc > 0 Then Debug.Print "GetPictureArray() failed, error code: " & rc Exit Sub End If Dim pic_path As String pic_path = Environ("TEMP") & "\bar.bmp" ' Storing the barcode picture in the temporary folder Dim arr() As Byte arr = v ' Do not write the VARIANT structure into the file! fn = FreeFile() Open pic_path For Binary Access Write As fn Put #fn, , arr Close #fn Shell "explorer.exe " & pic_path ' Showing the picture End Sub

GetZebraBitsU

Returns the bit pattern of the current barcode image. 1 represents the black module, 0 represents the white module.

This is the same function as the ZebraBits in the ActiveX/Class. For more information, see the ActiveX documentation.

Syntax

Parameters:

Return value

Remarks

The function provides limited functionality in free version of the barcode generator.

Example

Private Sub Test() Dim rc As Long rc = Initialize() If rc <> 0 Then Debug.Print "Initialize() failed, error code = " & rc Exit Sub End If SetLongPropU StrPtr("Alphabet"), 25 'QRCODE Dim text As String text = "ABCDE3457" rc = SetTextPropU(StrPtr("Text"), StrPtr(text)) If rc > 0 Then Debug.Print "SetTextPropU() failed, error code: " & rc Exit Sub End If zebra = String(32000, vbNullChar) l = Len(zebra) rc = GetZebraBitsU(StrPtr(zebra), l) If rc <> 0 Then Debug.Print "GetZebraBits() failed, error code: " & rc Exit Sub End If zebra = Left(zebra, l) Debug.Print zebra End Sub

GetFontOutU/GetFontOutA

Returns a text string intended to display the barcode using specialized TrueType font.

This is the same function as the FontOut in the ActiveX/Class. For more information, see the ActiveX documentation.

Syntax

Parameters:

Return value

Remarks

The function provides limited functionality in free version of the barcode generator.

Example

Private Sub Test_E() Dim rc As Long rc = Initialize() If rc <> 0 Then Debug.Print "Initialize() failed, error code = " & rc Exit Sub End If SetLongPropU StrPtr("Alphabet"), 25 'QRCODE Dim text As String text = "ABCDE3457" rc = SetTextPropU(StrPtr("Text"), StrPtr(text)) If rc > 0 Then Debug.Print "SetTextProp() failed, error code: " & rc Exit Sub End If fo = String(32000, vbNullChar) l = Len(fo) rc = GetFontOutU(StrPtr(fo), l) If rc <> 0 Then Debug.Print "GetFontOut() failed, error code: " & rc Exit Sub End If fo = Left(fo, l) Debug.Print fo End Sub

Function Definitions for VB/VBA

Below are the VB/VBA function definitions for 32-bit and 64-bit apps. Copy them into your code.

#If VBA7 Then #If Win64 Then Private Declare PtrSafe Function Initialize Lib "StrokeScribeDL64.dll" () As Long Private Declare PtrSafe Function GetVer Lib "StrokeScribeDL64.dll" (ByRef major As Long, ByRef major2 As Long, ByRef minor As Long) As Long Private Declare PtrSafe Function SetLongPropU Lib "StrokeScribeDL64.dll" (ByVal name As LongPtr, ByVal val As Long) As Long Private Declare PtrSafe Function SetDoublePropU Lib "StrokeScribeDL64.dll" (ByVal name As LongPtr, ByVal val As Double) As Long Private Declare PtrSafe Function SetTextPropU Lib "StrokeScribeDL64.dll" (ByVal name As LongPtr, ByVal val As LongPtr) As Long Private Declare PtrSafe Function SetVariantPropU Lib "StrokeScribeDL64.dll" (ByVal name As LongPtr, ByRef val As Variant) As Long Private Declare PtrSafe Function GetLongPropU Lib "StrokeScribeDL64.dll" (ByVal name As LongPtr, ByRef val As Long) As Long Private Declare PtrSafe Function SavePictureU Lib "StrokeScribeDL64.dll" (ByVal filename As LongPtr, ByVal format As Long, ByVal w As Long, ByVal h As Long, ByVal dpi As Long) As Long Private Declare PtrSafe Function GetZebraBitsU Lib "StrokeScribeDL64.dll" (ByVal zebra As LongPtr, ByRef size As Long) As Long Private Declare PtrSafe Function GetFontOutU Lib "StrokeScribeDL64.dll" (ByVal out As LongPtr, ByRef size As Long) As Long Private Declare PtrSafe Function GetPictureArray Lib "StrokeScribeDL64.dll" (ByRef arr As Variant, ByVal format As Long, ByVal w As Long, ByVal h As Long, ByVal dpi As Long) As Long #Else Private Declare PtrSafe Function Initialize Lib "StrokeScribeDL.dll" () As Long Private Declare PtrSafe Function GetVer Lib "StrokeScribeDL.dll" (ByRef major As Long, ByRef major2 As Long, ByRef minor As Long) As Long Private Declare PtrSafe Function SetLongPropU Lib "StrokeScribeDL.dll" (ByVal name As LongPtr, ByVal val As Long) As Long Private Declare PtrSafe Function SetDoublePropU Lib "StrokeScribeDL.dll" (ByVal name As LongPtr, ByVal val As Double) As Long Private Declare PtrSafe Function SetTextPropU Lib "StrokeScribeDL.dll" (ByVal name As LongPtr, ByVal val As LongPtr) As Long Private Declare PtrSafe Function SetVariantPropU Lib "StrokeScribeDL.dll" (ByVal name As LongPtr, ByRef val As Variant) As Long Private Declare PtrSafe Function GetLongPropU Lib "StrokeScribeDL.dll" (ByVal name As LongPtr, ByRef val As Long) As Long Private Declare PtrSafe Function SavePictureU Lib "StrokeScribeDL.dll" (ByVal filename As LongPtr, ByVal format As Long, ByVal w As Long, ByVal h As Long, ByVal dpi As Long) As Long Private Declare PtrSafe Function GetZebraBitsU Lib "StrokeScribeDL.dll" (ByVal zebra As LongPtr, ByRef size As Long) As Long Private Declare PtrSafe Function GetFontOutU Lib "StrokeScribeDL.dll" (ByVal out As LongPtr, ByRef size As Long) As Long Private Declare PtrSafe Function GetPictureArray Lib "StrokeScribeDL.dll" (ByRef arr As Variant, ByVal format As Long, ByVal w As Long, ByVal h As Long, ByVal dpi As Long) As Long #End If #Else Private Declare Function Initialize Lib "StrokeScribeDL.dll" () As Long Private Declare Function GetVer Lib "StrokeScribeDL.dll" (ByRef major As Long, ByRef major2 As Long, ByRef minor As Long) As Long Private Declare Function SetLongPropU Lib "StrokeScribeDL.dll" (ByVal name As Long, ByVal val As Long) As Long Private Declare Function SetDoublePropU Lib "StrokeScribeDL.dll" (ByVal name As Long, ByVal val As Double) As Long Private Declare Function SetTextPropU Lib "StrokeScribeDL.dll" (ByVal name As Long, ByVal val As Long) As Long Private Declare Function SetVariantPropU Lib "StrokeScribeDL.dll" (ByVal name As Long, ByRef val As Variant) As Long Private Declare Function GetLongPropU Lib "StrokeScribeDL.dll" (ByVal name As Long, ByRef val As Long) As Long Private Declare Function SavePictureU Lib "StrokeScribeDL.dll" (ByVal fileName As Long, ByVal format As Long, ByVal w As Long, ByVal h As Long, ByVal dpi As Long) As Long Private Declare Function GetZebraBitsU Lib "StrokeScribeDL.dll" (ByVal zebra As Long, ByRef size As Long) As Long Private Declare Function GetFontOutU Lib "StrokeScribeDL.dll" (ByVal out As Long, ByRef size As Long) As Long Private Declare Function GetPictureArray Lib "StrokeScribeDL.dll" (ByRef arr As Variant, ByVal format As Long, ByVal w As Long, ByVal h As Long, ByVal dpi As Long) As Long #End If ' More barcode type constants - here Private Const CODE128A = 0 Private Const CODE128B = 1 Private Const CODE128C = 2 Private Const EAN13 = 3 Private Const CODE128 = 5 Private Const PDF417 = 6 Private Const DATAMATRIX = 8 Private Const EAN128 = 17 Private Const QRCODE = 25 Private Const GS1DATAMATRIX = 30 Private Const AZTEC = 33 ' Picture format constants for the SavePicture() function: Private Const BMP = 0 Private Const GIF = 1 Private Const PNG = 2 Private Const JPG = 3 Private Const EMF = 4 Private Const TIFF = 5 Private Const BMP24 = 6 Private Const WMF = 7

Programming Examples

How to get the DLL version

Private Sub Test_A() Dim rc As Long rc = Initialize() ' Always call Initialize() BEFORE using any other functions from the library! If rc <> 0 Then Debug.Print "Initialize() failed, error code = " & rc Exit Sub End If Dim verMajor, verMajor2, verMinor As Long GetVer verMajor, verMajor2, verMinor Debug.Print "DLL version: " & verMajor & "." & verMajor2 & "." & verMinor ' For example, 5.1.1 End Sub

How to create a picture of a linear barcode

Private Sub Test_B() Dim rc As Long rc = Initialize() If rc <> 0 Then Debug.Print "Initialize() failed, error code = " & rc Exit Sub End If SetLongPropU StrPtr("Alphabet"), 5 'CODE128 Dim text As String text = "ABCDE3457" rc = SetTextPropU(StrPtr("Text"), StrPtr(text)) If rc > 0 Then Debug.Print "SetTextProp() failed, error code: " & rc Exit Sub End If Dim w As Long rc = GetLongPropU(StrPtr("BITMAPW"), w) ' Property names are not case sensitive. The property gives us the minimum width of the bitmap in pixels. Dim pic_path As String pic_path = Environ("TEMP") & "\bar.bmp" rc = SavePictureU(StrPtr(pic_path), BMP, w * 3, 100, 0) ' 3-pixel-wide bars, 100-pixel-tall barcode If rc > 0 Then Debug.Print "SavePicture() failed, error code: " & rc Exit Sub End If End Sub

How to set font parameters of the human-readable text label

Private Sub Test_G() Dim rc As Long rc = Initialize() If rc <> 0 Then Debug.Print "Initialize() failed, error code = " & rc Exit Sub End If SetLongPropU StrPtr("Alphabet"), 5 SetLongPropU StrPtr("FontAntialiasing"), 0 SetTextPropU StrPtr("FontName"), StrPtr("Arial") SetLongPropU StrPtr("FontSize"), 40 SetLongPropU StrPtr("TextJustify"), 0 Dim w As Long rc = GetLongPropU(StrPtr("BITMAPW"), w) Dim pic_path As String pic_path = Environ("TEMP") & "\bar.bmp" rc = SavePictureU(StrPtr(pic_path), BMP, w * 4, w, 0) If rc > 0 Then Debug.Print "SavePicture() failed, error code: " & rc Exit Sub End If End Sub

How to customize PDF417

Private Sub Test_G() Dim rc As Long rc = Initialize() If rc <> 0 Then Debug.Print "Initialize() failed, error code = " & rc Exit Sub End If SetLongPropU StrPtr("Alphabet"), 6 'PDF417 SetLongPropU StrPtr("CompactPDF417"), 1 SetLongPropU StrPtr("PDF417ErrLevel"), 2 SetLongPropU StrPtr("PDF417ModuleAspectRatio"), 3 SetLongPropU StrPtr("PDF417Cols"), 10 SetLongPropU StrPtr("PDF417Rows"), 0 SetLongPropU StrPtr("PDF417HorzQuietZone"), 3 SetLongPropU StrPtr("PDF417VertQuietZone"), 4 Dim text As String text = "ABCDE3457" rc = SetTextPropU(StrPtr("Text"), StrPtr(text)) If rc > 0 Then Debug.Print "SetTextProp() failed, error code: " & rc Exit Sub End If Dim w, h As Long rc = GetLongPropU(StrPtr("BITMAPW"), w) rc = GetLongPropU(StrPtr("BITMAPH"), h) Dim pic_path As String pic_path = Environ("TEMP") & "\bar.bmp" rc = SavePictureU(StrPtr(pic_path), BMP, w * 4, h * 4, 0) If rc > 0 Then Debug.Print "SavePicture() failed, error code: " & rc Exit Sub End If End Sub