Requirements
Windows | Mac | ||
---|---|---|---|
x86 | x64 | x86_x64 | |
Header files |
If_DBRP.h BarcodeFormat.h BarcodeStructs.h CommonConfig.h ErrorCode.h ExportDefines.h |
If_DBRP.h BarcodeFormat.h BarcodeStructs.h CommonConfig.h ErrorCode.h ExportDefines.h |
If_DBRP.h BarcodeFormat.h BarcodeStructs.h CommonConfig.h ErrorCode.h ExportDefines.h |
Lib Files | DBRx86.lib | DBRx64.lib | libDynamsoftBarcodeReader.dylib |
Three Steps to Get Started [Windows]
-
Create an empty Win32 Console Application project, through Visual C++ > Win32. Let's name it BarcodeReaderDemo
In the main.cpp, please include the .H and .LIB files.
Please note, the .H files can be found in [INSTALL FOLDER]\Include\, and the .LIB files can be found in [INSTALL FOLDER]\Lib\.
Please replace <relative path> in the code with the relative path to the main.cpp file.#include <stdio.h> #include "<relative path>/If_DBRP.h" #ifdef _WIN64 #pragma comment(lib, "<relative path>/DBRx64.lib") #else #pragma comment(lib, "<relative path>/DBRx86.lib") #endif
BarcodeFormat.h, BarcodeStructs.h, CommonConfig.h, ErrorCode.h, ExportDefines.h
-
In the main.cpp, please add the main function.
Please update the <your image file full path> and <your license key here> with valid values respectively in the code.
The licenses can be found in the [INSTALL FOLDER]\LicenseManager.exe.int main(int argc, const char* argv[]) { //Define variables const char * pszImageFile = "<your image file full path>"; int iIndex = 0; int iRet = -1; //Initialize license prior to any decoding CBarcodeReader reader; reader.InitLicense("<your license key here>"); //Start decoding iRet = reader.DecodeFile(pszImageFile); //If not DBR_OK if (iRet != DBR_OK) { printf("Failed to read barcode: %d\r\n%s\r\n",iRet, DBR_GetErrorString(iRet)); return iRet; } //If DBR_OK pBarcodeResultArray paryResult = NULL; reader.GetBarcodes(&paryResult); printf("%d total barcodes found. \r\n", paryResult->iBarcodeCount); for (iIndex = 0; iIndex < paryResult->iBarcodeCount; iIndex++) { printf("Result %d\r\n", iIndex + 1); printf("PageNum: %d\r\n", paryResult->ppBarcodes[iIndex]->iPageNum); printf("BarcodeFormat: %lld\r\n", paryResult->ppBarcodes[iIndex]->llFormat); printf("Text read: %s\r\n", paryResult->ppBarcodes[iIndex]->pBarcodeData); } //Finally release BarcodeResultArray CBarcodeReader::FreeBarcodeResults(&paryResult); return 0; }
-
Build the application, and copy the DynamsoftBarcodeReaderx86.dll, DynamsoftBarcodeReaderx64.dll, DynamicPdf.dll and DynamicPdfx64.dll to the .EXE folder.
The DLLs can be found in [INSTALL FOLDER]\Redist\C_C++\.
To verify if it is working, please open the cmd.exe, and execute the .EXE with a barcode image.
To deploy your application, please make sure the DLLs are in the same folder as the EXE file. If your barcodes are from PDF files, DynamicPdf.dll and DynamicPdfx64.dll are mandatory.
Three Steps to Get Started [Mac]
-
Create an Command Line Tool project, through XCode > c++. Let's name it BarcodeReaderDemo
In the main.cpp, please include the .H files and add the .DYLIB files.
Please note, the .H files can be found in [INSTALL FOLDER]\Include\, and the .DYLIB files can be found in [INSTALL FOLDER]\Redist\.
Please replace <relative path> in the code with the relative path to the main.cpp file.#include <stdio.h> #include "<relative path>/If_DBRP.h"
Please make sure the following .H files are in the same folder as If_DBRP.h.
BarcodeFormat.h, BarcodeStructs.h, CommonConfig.h, ErrorCode.h, ExportDefines.h
-
In the main.cpp, please add the main function.
Please update the <your image file full path> and <your license key here> with valid values respectively in the code.
The licenses can be found in the [INSTALL FOLDER]\BarcodeReaderTrialLic.txt.int main(int argc, const char* argv[]) { //Define variables const char * pszImageFile = "<your image file full path>"; int iIndex = 0; int iRet = -1; //Initialize license prior to any decoding CBarcodeReader reader; reader.InitLicense("<your license key here>"); //Start decoding iRet = reader.DecodeFile(pszImageFile); //If not DBR_OK if (iRet != DBR_OK) { printf("Failed to read barcode: %d\r\n%s\r\n",iRet, DBR_GetErrorString(iRet)); return iRet; } //If DBR_OK pBarcodeResultArray paryResult = NULL; reader.GetBarcodes(&paryResult); printf("%d total barcodes found. \r\n", paryResult->iBarcodeCount); for (iIndex = 0; iIndex < paryResult->iBarcodeCount; iIndex++) { printf("Result %d\r\n", iIndex + 1); printf("PageNum: %d\r\n", paryResult->ppBarcodes[iIndex]->iPageNum); printf("BarcodeFormat: %lld\r\n", paryResult->ppBarcodes[iIndex]->llFormat); printf("Text read: %s\r\n", paryResult->ppBarcodes[iIndex]->pBarcodeData); } //Finally release BarcodeResultArray CBarcodeReader::FreeBarcodeResults(&paryResult); return 0; }
-
Debug or Run the code to verify if it is working!