barcode VC++ barcode VC++
barcode VC++ COM Object download

Print Barcode From Visual C++ Application

To print barcode from your own VC++ application, you need Barcodesoft true type fonts and cruflbcs.dll .

Barcodesoft software supports all major linear and 2D barcode symbologies: code39, code128, UPC-A, EAN-13, UCC/EAN-128, Interleaved 2 of 5, POSTNet .

If you download and install Barcodesoft demo software on your computer,
you will find crUFLBCS.dll from
"C:\Program Files (x86)\Common Files\Barcodesoft\Fontutil\" folder.

If you don't find cruflbcs.dll on your computer, please download it from Barcode VC++ .

crUFLBCS.dll is a COM object with ILinear interface.
You can find detailed information about this interface from readme.html.

To call the methods of this barcode interface from VC++, you can use either Late Binding or Early Binding.
Late binding is used when type information of an object is unavailable at compile time.
Early binding requires the client to get access to the type library before compile.

Late Binding

Your codes to create barcode in VC++ application run slower than using Early Binding.
However, your codes are supposed to be version-independent as long as COM interface
and method parameters remain unchanged.
CLSID clsid;
if (FAILED(::CLSIDFromProgID(L"cruflbcs.Linear.1", &clsid)))
return 0;
IDispatch* pIDispatch = NULL;
if (FAILED(::CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IDispatch, (void**)&pIDispatch)))
return 0;
LPOLESTR szNameEncode = L"UCCEAN128";
DISPID dispid_uccean128;
HRESULT hr = pIDispatch->GetIDsOfNames(IID_NULL, &szNameEncode, 1, LOCALE_SYSTEM_DEFAULT, &dispid_uccean128);
CComBSTR bstrResult;
v[0].vt = VT_BSTR; v[0].bstrVal = SysAllocString(L"..."); // <==put your data here
DISPPARAMS dispParams = { v, NULL, 1, 0 };
VARIANT vResult;
hr = pIDispatch->Invoke( dispid_uccean128, IID_NULL, GetUserDefaultLCID(), DISPATCH_METHOD,
&dispParams, &vResult, NULL, NULL);
if (FAILED(hr))
return 0;

Early Binding

Your codes to create barcode in VC++ application run faster than using Late Binding.

1. Import type library. Don't forget to call
CoInitialize() before using COM interface.

2. If you want to use T2OLE macro to convert
LPTSTR into LPOLESTR, you need to call USES_CONVERSION macro first.
#include <atlbase.h>
#include <atlconv.h>

#import "cruflbcs.dll"
using namespace cruflBCS;

_bstr_t bstrOutput;
char pszToEncode[] = "..."; // <==put your data here
cruflBCS::ILinearPtr pBCSLinear(__uuidof(cruflBCS::CLinear));
bstrOutput = pBCSLinear->UCCEAN128(pszToEncode);
catch (const _com_error& e)
_tprintf(_T("Error: 0x%08x %s\n"), e.Error(), e.ErrorMessage());

barcode VC++ MFC Wrapper class

Use MFC to Generate Wrapper Class

If you use VC++ 6 to create barcode, press Ctrl + W to start Class Wizard. Then click "Add Class" button, choose "From a type library".
Choose crUFLBCS.dll, and then select all barcode Interfaces you want to add wrappers and click OK.

If you use Visual Studio 2003 or above to generate barcode,
1. On the Project menu, select Add Class.
2. Select MFC Class from Typelib from the list of templates.
3. For Add Class from, select Registry.
4. In the list of available type libraries, find crUFLBCS.
5. From the list of interfaces in that type library, select all classes for which you want to add wrappers.
6. Click Finish.

Please don't forget to call OleInitialize(NULL) before using the following code snippet.
CString strOutput;
IBarcode *pBarcodeObj = new ILinear();
if ( pBarcodeObj->CreateDispatch("cruflbcs.Linear.1")
strOutput = pBarcodeObj->UCCEAN128("...");