ByteScout BarCode Generator SDK - C++ - Generate Barcode - ByteScout

ByteScout BarCode Generator SDK – C++ – Generate Barcode

  • Home
  • /
  • Articles
  • /
  • ByteScout BarCode Generator SDK – C++ – Generate Barcode

How to Generate Barcode in C++ with ByteScout Barcode SDK

This Tutorial Will Show How to Generate Barcode in C++

We made thousands of pre-made source code pieces for easy implementation in your own programming projects. ByteScout Barcode SDK is the robust library (Software Development Kit) that is designed for the automatic generation of high-quality barcodes for printing, electronic documents, and PDF. All popular barcode types are supported from Code 39 and Code 129 to QR Code, UPC, GS1, GS-128, Datamatrix, PDF417, Maxicode, and many others. Provides support for full customization of fonts, colors, output, and printing sizes. Special tools are included to verify output quality and printing quality. Can add generated barcodes into new or existing documents, images, and PDF. It can generate barcodes in C++.

You will save a lot of time on writing and testing code as you may just take the C++ code from ByteScout Barcode SDK to generate the barcode below and use it in your application. Follow the instructions from scratch to work and copy the C++ code. Detailed tutorials and documentation are available along with installed ByteScout Barcode SDK if you’d like to dive deeper into the topic and the details of the API.

You can download a free trial version of ByteScout Barcode SDK from our website to see and try many others source code samples for C++.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)


#include "stdafx.h" #import "Bytescout.BarCode.tlb" raw_interfaces_only using namespace Bytescout_BarCode; int _tmain(int argc, _TCHAR* argv[]) { // Initialize COM. HRESULT hr = CoInitialize(NULL); // Create the interface pointer. IBarcodePtr pIBarcode(__uuidof(Barcode)); // set the registration name and key BSTR regname = ::SysAllocString(L"DEMO"); pIBarcode->put_RegistrationName(regname); ::SysFreeString(regname); BSTR regkey = ::SysAllocString(L"DEMO"); pIBarcode->put_RegistrationKey(regkey); ::SysFreeString(regkey); // Set barcode type (symbology) pIBarcode->put_Symbology(SymbologyType_Code128); // Set barcode value BSTR value = ::SysAllocString(L"Abc123"); pIBarcode->put_Value(value); ::SysFreeString(value); // Save barcode image BSTR fileName = ::SysAllocString(L"result.png"); pIBarcode->SaveImage(fileName); ::SysFreeString(fileName); pIBarcode->Release(); // Uninitialize COM. CoUninitialize(); return 0; }


// stdafx.cpp : source file that includes just the standard includes // BarcodeGenerationExample.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file


// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #include "targetver.h" #include <stdio.h> #include <tchar.h> // TODO: reference additional headers your program requires here


#pragma once // Including SDKDDKVer.h defines the highest available Windows platform. // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. #include <SDKDDKVer.h>


60 Day Free Trial or Visit ByteScout Barcode SDK Home Page

Explore ByteScout Barcode SDK Documentation

Explore Samples

Sign Up for ByteScout Barcode SDK Online Training


Get Your API Key

Explore Web API Docs

Explore Web API Samples