如何检查扫描仪是否已插入(C#、. NET TWAIN) [英] How do I check if the scanner is plugged in (C#, .NET TWAIN)

查看:105
本文介绍了如何检查扫描仪是否已插入(C#、. NET TWAIN)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 http中的.NET TWAIN代码://www.codeproject.com/KB/dotnet/twaindotnet.aspx?msg = 1007385#xx1007385xx . 当我在未插入扫描仪的情况下尝试扫描图像时,该应用程序将冻结.

I'm using the .NET TWAIN code from http://www.codeproject.com/KB/dotnet/twaindotnet.aspx?msg=1007385#xx1007385xx in my application. When I try to scan an image when the scanner is not plugged in, the application freezes.

如何使用TWAIN驱动程序检查设备是否已插入?

How can I check if the device is plugged in, using the TWAIN driver?

推荐答案

也许我从字面上考虑了这个问题,但是使用TWAIN API,无法检查设备是否已插入(即已连接并已打开电源) . TWAIN标准确实为此目的定义了一种称为CAP_DEVICEONLINE的功能,但是该功能构想太差,几乎没有任何驱动程序正确地实现,以至于在实践中毫无用处.

Maybe I'm taking the question too literally, but using the TWAIN API, it is not possible to check if a device is plugged in i.e. connected and powered on. The TWAIN standard does define a capability for this purpose called CAP_DEVICEONLINE, but this feature is so poorly conceived and so few drivers implement it correctly that it is useless in practice.

您可以找到的最接近的是:打开设备(MSG_OPENDS):几乎所有驱动程序在打开时都会检查设备是否就绪,并向用户显示错误对话框. 没有用于抑制或检测该对话框的TWAIN机制一些驱动程序将允许用户纠正问题并继续,在这种情况下,您(您的应用程序)将永远不会知道有问题.一些驱动程序将允许用户取消,在这种情况下,MSG_OPENDS操作将失败,可能返回TWRC_CANCEL,但可能会返回TWRC_FAILURE

The closest you can get is this: Open the device (MSG_OPENDS): Almost all drivers will check for device-ready when they are opened, and will display an error dialog to the user. There is no TWAIN mechanism for suppressing or detecting this dialog Some drivers will allow the user to correct the problem and continue, in which case you (your app) will never know there was a problem. Some drivers will allow the user to cancel, in which case the MSG_OPENDS operation will fail, probably returning TWRC_CANCEL but maybe TWRC_FAILURE

即使设备处于脱机状态,也会打开一些TWAIN驱动程序而不会出现错误.这样的驱动程序可以将FALSE返回到CAP_DEVICEONLINE的查询.当您使用MSG_ENABLEDS启用设备时,这样的驱动程序可能会进行设备在线检查,然后,如果设备不在线,则会向用户显示错误对话框,依此类推.

A few TWAIN drivers will open without error even though the device is off-line. Such a driver may return FALSE to a query of CAP_DEVICEONLINE. Such a driver will probably do the device-online check when you enable the device with MSG_ENABLEDS, and then if the device is not on-line, you get the error dialog to the user, and so on as above.

此外,IMPO:WIA比TWAIN更加现代",但扫描的综合性却差很多,以我的经验,它不能用于从文档进纸器进行多页扫描. WIA的设计人员和维护人员似乎不了解或不在意低端家用平板扫描仪.这对相机很有好处.

Aside and IMPO: WIA is 'more modern' but also much less comprehensive for scanning than TWAIN, and in my experience unusable for multipage scanning from a document feeder. WIA's designers and maintainers seem not to understand or care about scanners other than low-end consumer flatbeds. It's good for cameras.

这篇关于如何检查扫描仪是否已插入(C#、. NET TWAIN)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆