版主你好,由于集成了比较多东西,工程文件大,我这里把启动扫描的代码发出来,你新建工程粘贴下就:在窗体的Load事件里执行:
twnSession= twnSession = new TwainSession();
在开始扫描按钮执行:
Action action = new Action(StartScan);
action.BeginInvoke(ScanFinishCallBack, null);
private void StartScan()
{
try
{
ScanConfigInfo config = ScanConfigInfo.GetActivityScanConfig();
session.Startup(IntPtr.Zero, "Qs Technologies, Inc.", "QsScanApp", "Version 1.0", "QsScanApp", TwainStartupFlags.None);
session.SelectSource(config.ScanDevice);
InitTwainSessionByConfig(config);
session.AcquirePage += TwainSession_AcquirePage;
session.Acquire(TwainUserInterfaceFlags.None);
session.AcquirePage -= TwainSession_AcquirePage;
session.Shutdown();
}
catch (Exception ex)
{
XtraMessageBox.Show("启动扫描仪出错(" + ex.Message + ")", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
finally
{
SetBtnEnableForStartOrStop(false);
}
}
private void ScanFinishCallBack(IAsyncResult result)
{
if (result.IsCompleted)
{
//SetBtnEnableForStartOrStop(false);
}
}
在停止按钮中执行:
session.StopFeeder();
|