ByteScout Premium Suite - C++ - Get barcode to memory buffer with barcode sdk - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout Premium Suite – C++ – Get barcode to memory buffer with barcode sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Premium Suite – C++ – Get barcode to memory buffer with barcode sdk

How to get barcode to memory buffer with barcode sdk in C++ and ByteScout Premium Suite

How to write a robust code in C++ to get barcode to memory buffer with barcode sdk with this step-by-step tutorial

Get barcode to memory buffer with barcode sdk is simple to apply in C++ if you use these source codes below. ByteScout Premium Suite is the bundle that includes twelve SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording. It can get barcode to memory buffer with barcode sdk in C++.

The following code snippet for ByteScout Premium Suite works best when you need to quickly get barcode to memory buffer with barcode sdk in your C++ application. This C++ sample code is all you need for your app. Just copy and paste the code, add references (if needs to) and you are all set! Further improvement of the code will make it more robust.

ByteScout Premium Suite free trial version is available on our website. C++ and other programming languages are supported.

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

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

BarcodeGenerationExample.cpp
      
#include "stdafx.h" #include <atlsafe.h> // For ATL::CComSafeArray #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); // Get barcode image bytes. SAFEARRAY* pSafeArray; pIBarcode->GetImageBytesPNG(&pSafeArray); // Convert SAFEARRAY to byte array CComSafeArray<BYTE> safeArray; safeArray.Attach(pSafeArray); UINT count = safeArray.GetCount(); BYTE* bytes = new BYTE[count]; for (ULONG i = 0; i < count; i++) bytes[i] = safeArray.GetAt(i); // Check result by saving image bytes to file FILE* pFile; fopen_s(&pFile, "result.png", "wb"); fwrite(bytes, 1, count, pFile); fclose(pFile); delete[] bytes; pIBarcode->Release(); // Uninitialize COM. CoUninitialize(); return 0; }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Premium Suite Home Page

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

stdafx.cpp
      
// 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

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Premium Suite Home Page

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

stdafx.h
      
// 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

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Premium Suite Home Page

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

targetver.h
      
#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>

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Premium Suite Home Page

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Premium Suite Home Page

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next