FindFastConfig example for C++ Builder
int __fastcall TForm1::LEADTwain1FastConfigEvent(pFASTCONFIG pResConfig)
{
AnsiString strBuffer;
if ( pResConfig->bSuccess )
{
strBuffer= "Transfer Mode = "+ IntToStr(pResConfig->uTransferMode) + "\n" +
"File Format = " + IntToStr(pResConfig->nFileFormat) + "\n" +
"Buffer Size = " + IntToStr(pResConfig->ulBufferSize) + "\n" +
"Required Time = " + IntToStr(pResConfig->uTime) + "\n";
MessageBox ( Handle, strBuffer.c_str( ), "Result Scan Configuration...", MB_OK );
}
else
MessageBox ( Handle, "The tested configuration failed…", "Error!", MB_OK );
return SUCCESS;
}
void __fastcall TForm1::btnFindFastConfigClick(TObject *Sender)
{
L_INT nRet;
pFASTCONFIG pTestConfigs= NULL;
L_INT nTestConfigsCount= 0;
pFASTCONFIG pFastConfg;
L_INT nFastConfigCount;
FASTCONFIG BestConfig;
AnsiString strBuffer;
nRet= LEADTwain1->GetScanConfigs ( 1, LTWAIN_BUFFER_MODE, 5, &pFastConfg, &nFastConfigCount );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Error occurred while getting the scan configurations for the Memory transfer mode!!!", "Error!!!", MB_OK );
return;
};
FillMemory ( &BestConfig, sizeof(FASTCONFIG), 0 );
LEADTwain1->EnableFastConfigEvent = true;
nRet= LEADTwain1->FindFastConfig ( "c:\\TWAIN",
LTWAIN_SHOW_USER_INTERFACE,
1,
5,
pFastConfg,
nFastConfigCount,
&pTestConfigs,
&nTestConfigsCount,
&BestConfig );
if ( nRet == SUCCESS )
{
MessageBox ( Handle, "FindFastConfig method was successful.", "Notice", MB_OK );
strBuffer= "Transfer Mode = " + IntToStr(BestConfig.uTransferMode) + "\n" +
"File Format = " + IntToStr(BestConfig.nFileFormat) + "\n" +
"Buffer Size = " + IntToStr(BestConfig.ulBufferSize) + "\n" +
"Required Time = " + IntToStr(BestConfig.uTime);
MessageBox ( Handle, strBuffer.c_str( ), "Best Scan Configuration...", MB_OK );
LEADTwain1->FreeScanConfig ( &pTestConfigs, nTestConfigsCount );
}
else
{
MessageBox( Handle, "Error occurred in the FindFastConfig method!!!", "Error!!!", MB_OK );
LEADTwain1->FreeScanConfig ( &pFastConfg, nFastConfigCount );
}
}