Nicomsoft OCR: Developer's Guide |
C++: | int Scan_Enumerate(HSCAN ScanObj, UNICODECHAR* ScannerNames, int MaxLen, int Flags) |
C#: | int Scan_Enumerate(int ScanObj, out string ScannerNames, int Flags) |
Visual Basic: | Function Scan_Enumerate(ByVal ScanObj As Integer, ByRef ScannerNames As String, ByVal Flags As Integer) As Integer |
Java: | int Scan_Enumerate(HSCAN ScanObj, StringBuffer ScannerNames, int Flags) |
Delphi: | function Scan_Enumerate(ScanObj:HSCAN; ScannerNames:PWCHAR; MaxLen:integer; Flags:integer):integer |
ScanObj [IN] – the Scan object. | |
ScannerNames [OUT] – the buffer that will get the Unicode, null-terminated string containing a comma-separated list of available scanner names. | |
MaxLen [IN] – the buffer size, in Unicode characters, including the null termination character. If 0, then the function will not copy anything to the buffer, but will only return the buffer size (in Unicode characters, without the null termination character) needed to store scanner names. | |
Flags [IN] – the flags. See the SCAN_XXXXX constants for possible values. |
int CfgObj, ScanObj, res, n; Engine_Initialize(); //initialize OCR engine Cfg_Create(&CfgObj); //create CFG object Cfg_LoadOptions(CfgObj, L"Config.dat"); //load configuration Scan_Create(CfgObj, &ScanObj); //create Scan object n = Scan_Enumerate(ScanObj, NULL, 0, 0) + 1; //get length in unicode characters plus terminating NULL character if (n > ERROR_FIRST) {}; //insert error handler here wchar_t* txt = (wchar_t*) malloc(2 * n); //allocate memory for text n = Scan_Enumerate(ScanObj, txt, n, 0); //enumerate scanners //use "txt" variable now, it contains the list of available TWAIN devices separated by comma free(txt); //free memory Engine_Uninitialize(); //release all created objects and uninitialize OCR engine
//assume reference to NSOCR COM was added using NSOCR_NameSpace; //Add NSOCR namespace from "NSOCR.cs" file //... int CfgObj, ScanObj, res; string txt; NSOCRLib.NSOCRClass NsOCR = new NSOCRLib.NSOCRClass(); //create NSOCR COM object instance NsOCR.Engine_Initialize(); //initialize OCR engine NsOCR.Cfg_Create(out CfgObj); //create CFG object NsOCR.Cfg_LoadOptions(CfgObj, "Config.dat"); //load configuration NsOCR.Scan_Create(CfgObj, out ScanObj); //create Scan object res = NsOCR.Scan_Enumerate(ScanObj, out txt, 0); //enumerate scanners if (res > TNSOCR.ERROR_FIRST) {}; //insert error handler here //use "txt" variable now, it contains the list of available TWAIN devices separated by comma NsOCR.Engine_Uninitialize(); //release all created objects and uninitialize OCR engine
'assume reference to NSOCR COM was added 'assume "NSOCR.vb" file was added to project Dim CfgObj, ScanObj, res As Integer Dim txt As String = "" Dim NsOCR As New NSOCRLib.NSOCRClass 'create NSOCR COM object instance NsOCR.Engine_Initialize() 'initialize OCR engine NsOCR.Cfg_Create(CfgObj) 'create CFG object NsOCR.Cfg_LoadOptions(CfgObj, "Config.dat") 'load configuration NsOCR.Scan_Create(CfgObj, ScanObj) 'create Scan object res = NsOCR.Scan_Enumerate(ScanObj, txt, 0) 'enumerate scanners If res > TNSOCR.ERROR_FIRST Then 'insert error handler here End If 'use "txt" variable now, it contains the list of available TWAIN devices separated by comma NsOCR.Engine_Uninitialize() 'release all created objects and uninitialize OCR engine
//assume NSOCR package was included //Java VM option "-Djava.library.path" must point to "Bin" folder (x86 platform) or to "Bin_64" folder (x64 platform) //... NSOCR.HCFG CfgObj = new NSOCR.HCFG(); NSOCR.HSCAN ScanObj = new NSOCR.HSCAN(); int res; StringBuffer txt = new StringBuffer(); NSOCR.Engine.Engine_Initialize(); //initialize OCR engine NSOCR.Engine.Cfg_Create(CfgObj); //create CFG object NSOCR.Engine.Cfg_LoadOptions(CfgObj, "Config.dat"); //load configuration NSOCR.Engine.Scan_Create(CfgObj, ScanObj); //create Scan object res = NSOCR.Engine.Scan_Enumerate(ScanObj, txt, 0); //enumerate scanners if (res > NSOCR.Error.ERROR_FIRST) {}; //insert error handler here //use "txt" variable now, it contains the list of available TWAIN devices separated by comma System.out.println(txt.toString()); NSOCR.Engine.Engine_Uninitialize(); //release all created objects and uninitialize OCR engine