Using Encoder DLL for Morovia Barcode Fonts

To assist our customers integrating barcode fonts with their own applications, we provide a series of source code written in a variety of languages, such as Visual Basic, VBScript, C/C++, FoxPro and JavaScript. You are allowed to import and modify these source code to fit your applications.

In many cases, using a Windows DLL is easier from code maintenance perspective. Some encoder functions, such as Code128Ex and EAN128Ex, are only available through the DLL.

This encoder DLL supports the following font products: Code39, Code39 Full ASCII, Code93,Code128, code25, Code11, Codabar, Interleaved 2of5, UPC/EAN/Bookland, US Postal, Royal Mail and Telepen. Other font products, such as OCR, MICR E-13B and CMC-7, require no check digit calculation at all.

For two dimensional barcode fonts, the encoder is included in the font product.

Where to Find this Encoder DLL

The encoder DLL is part of Font Tools package, which is included in every linear barcode font product. The files are located at [Program Files]common files\morovia\MoroviaFontTools directory. The name of the encoder DLL is mrvFontTools.dll.

The Font Tools can be downloaded separately at here.

Using DLL functions in Visual Basic 6

We recommend you place our DLL under the Windows directory, or you can place the DLL under the same directory of your application. In either case you need to make sure that the DLL is search-able by your application.

Declaring a DLL Function

The first step is to declare the procedure in the Declarations section of a module:

  Private Declare Function Code128Ex Lib "MrvFontTools" _ Alias "Code128Ex" _
        (ByRef lpString As String) As String  

To get the definition of the function, refer to the function prototype. If you place the Declare in a Form or Class module, you must precede it with the Private keyword. You only need to declare the function once per project; you can then call it any number of times.

Calling a DLL Function

After the function is declared, you call it just as you would a standard Visual Basic function. Here, the procedure has been attached to the Form_Load event:

  Private Sub Form_Load()      
    TextBox1.Text = Code128Ex("00001344556")
  End Sub 

How to Use DLL functions in C/C++

A robust way to use DLL in a C/C++ program is to dynamically load the DLL into the memory, obtain the function address and call the function. The following code demonstrates how to:

 #include <windows.h>
 #include <iostream.h>
 #include <stdio.h>
 #include <conio.h>

 #define MAXMODULE 50
 typedef char* (WINAPI*cfunc)(const char*);
 cfunc encode_func;

 void main() {
   HINSTANCE hLib=LoadLibrary("MrvFontTools.DLL");
   if(hLib==NULL) {
     cout << "Unable to load library!" << endl;
   encode_func=(cfunc)GetProcAddress((HMODULE)hLib, "Code128Ex");

   char* p = encode_func("0001233000");