FindFastConfig example for Delphi
Function TForm1.LEADTwain1FastConfigEvent(
pResConfig: pFASTCONFIG): Integer;
var
strBuffer: String;
begin
if ( pResConfig.bSuccess ) then
begin
strBuffer:= 'Transfer Mode = '+ IntToStr(pResConfig.uTransferMode) + Chr(13) +
'File Format = ' + IntToStr(pResConfig.nFileFormat) + Chr(13) +
'Buffer Size = ' + IntToStr(pResConfig.ulBufferSize) + Chr(13) +
'Required Time = ' + IntToStr(pResConfig.uTime) + Chr(13);
MessageBox ( Handle, PChar(strBuffer), 'Result Scan Configuration...', MB_OK );
end
else
MessageBox ( Handle, 'The tested configuration failed…', 'Error!', MB_OK );
Result:= SUCCESS;
end;
procedure TForm1.btnFindFastConfigClick(Sender: TObject);
var
nRet: L_INT;
pTestConfigs: pFASTCONFIG;
nTestConfigsCount: L_INT;
pFastConfg: pFASTCONFIG;
nFastConfigCount: L_INT;
BestConfig: FASTCONFIG;
strBuffer: String;
begin
pTestConfigs:= Nil;
nTestConfigsCount:= 0;
nRet:= LEADTwain1.GetScanConfigs ( 1, LTWAIN_BUFFER_MODE, 5, @pFastConfg, @nFastConfigCount );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Error occurred while getting the scan configurations for the Memory transfer mode!!!', 'Error!!!', MB_OK );
Exit;
end;
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 ) then
begin
MessageBox ( Handle, 'FindFastConfig method was successful.', 'Notice', MB_OK );
strBuffer:= 'Transfer Mode = ' + IntToStr(BestConfig.uTransferMode) + Chr(13) +
'File Format = ' + IntToStr(BestConfig.nFileFormat) + Chr(13) +
'Buffer Size = ' + IntToStr(BestConfig.ulBufferSize) + Chr(13) +
'Required Time = ' + IntToStr(BestConfig.uTime);
MessageBox ( Handle, PChar(strBuffer), 'Best Scan Configuration...', MB_OK );
LEADTwain1.FreeScanConfig ( @pTestConfigs, nTestConfigsCount );
end
else
begin
MessageBox( Handle, 'Error occurred in the FindFastConfig method!!!', 'Error!!!', MB_OK );
LEADTwain1.FreeScanConfig ( @pFastConfg, nFastConfigCount );
end;
end;