ByteScout Premium Suite - C++ - Read barcode from memory with barcode reader sdk - ByteScout

ByteScout Premium Suite – C++ – Read barcode from memory with barcode reader sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Premium Suite – C++ – Read barcode from memory with barcode reader sdk

How to read barcode from memory with barcode reader sdk in C++ and ByteScout Premium Suite

Step-by-step tutorial on how to read barcode from memory with barcode reader sdk in C++

The coding instructions are formulated to help you to try-out the features without the requirement to write your own code. 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 read barcode from memory with barcode reader sdk in C++.

This prolific sample source code in C++ for ByteScout Premium Suite contains various functions and other necessary options you should do calling the API to read barcode from memory with barcode reader sdk. Simply copy and paste in your C++ project or application you and then run your app! Enjoy writing a code with ready-to-use sample C++ codes.

If you want to try other source code samples then the free trial version of ByteScout Premium Suite is available for download from our website. Just try other 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)

ReadFromMemory.cpp
      
// ReadFromMemory.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "atlbase.h" #import "c:\\Program Files\\Bytescout BarCode Reader SDK\\net4.00\\Bytescout.BarCodeReader.tlb" raw_interfaces_only using namespace Bytescout_BarCodeReader; int _tmain(int argc, _TCHAR* argv[]) { // Initialize COM. HRESULT hr = CoInitialize(NULL); // Create the interface pointer. IReaderPtr pIReader(__uuidof(Reader)); // set the registration name and key BSTR regname = ::SysAllocString(L"DEMO"); pIReader->put_RegistrationName(regname); SysFreeString(regname); BSTR regkey = ::SysAllocString(L"DEMO"); pIReader->put_RegistrationKey(regkey); SysFreeString(regkey); // Set barcode type to find _BarcodeTypeSelectorPtr pBarcodeTypesToFind; pIReader->get_BarcodeTypesToFind(&pBarcodeTypesToFind); pBarcodeTypesToFind->put_GS1DataBarExpanded(VARIANT_TRUE); // Get full path of sample barcode image file WCHAR file[MAX_PATH]; ::GetFullPathName(L"GS1DataBarExpanded.png", MAX_PATH, file, NULL); // Load file content to byte array (for demonstration purpose) HANDLE hFile = CreateFile(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); DWORD fileSize = GetFileSize(hFile, NULL); byte* pBuffer = new byte[fileSize]; DWORD numberOfBytesRead; ReadFile(hFile, pBuffer, fileSize, &numberOfBytesRead, NULL); CloseHandle(hFile); // Read barcode from memory IStream* stream = SHCreateMemStream(pBuffer, fileSize); hr = pIReader->ReadFromStream(stream); stream->Release(); delete[] pBuffer; // Get found barcode count long count; pIReader->get_FoundCount(&count); // Get found barcode information for (int i = 0; i < count; i++) { SymbologyType type; hr = pIReader->GetFoundBarcodeType(i, &type); wprintf(L"Barcode type: %d\n", type); float confidence; hr = pIReader->GetFoundBarcodeConfidence(i, &confidence); wprintf(L"Barcode confidence: %f\n", confidence); BSTR bstrValue; hr = pIReader->GetFoundBarcodeValue(i, &bstrValue); wprintf(L"Barcode value: %s\n", bstrValue); ::SysFreeString(bstrValue); wprintf(L"\n"); } if (count == 0) { wprintf(L"no barcodes found"); } // Uninitialize COM. CoUninitialize(); wprintf(L"\nHit key to continue\n"); getchar(); 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 // ReadFromMemory.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