c# - 在 Windows 7 上使用 WIFI 扫描多个页面

标签 c# windows-7 scanning wia

我正在尝试从进纸器扫描几页,尽管当我调用 ShowTransfer 函数时扫描仪会自动扫描所有页面(不使用循环),但我只返回第一页。

我究竟做错了什么?

这是我的代码:

  WIA.Item item = device.Items[1] as WIA.Item;

            if (pages > 1)
            {
                // Set to feeder
                SetWIAProperty(device.Properties, 44, 1);
            }

            SetWIAProperty(device.Properties, WIA_DEVICE_PROPERTY_PAGES_ID, 1);

            AdjustScannerSettings(item, 150, 0, 0, 1250, 1700, 0, 0, 1);
            try
            {

                // scan image
                WIA.ICommonDialog wiaCommonDialog = new WIA.CommonDialog();
                WIA.ImageFile image = (WIA.ImageFile)wiaCommonDialog.ShowTransfer(item, wiaFormatBMP, false);

                // save to temp file
                string fileName = Path.GetTempFileName();
                File.Delete(fileName);
                image.SaveFile(fileName);
                image = null;
                // add file to output list
                images.Add(Image.FromFile(fileName));
            }
            catch (Exception exc)
            {
                throw exc;
            }

最佳答案

我认为这个链接正在做你想做的事

http://forums.codeguru.com/showthread.php?439027-Windows-Image-Acquisition-(WIA)-Code

基本上,您需要在保存每个页面后检查以查看是否还有更多页面并继续循环

                hasMorePages = false; //assume there are no more pages
                if (documentHandlingSelect != null)
                    //may not exist on flatbed scanner but required for feeder
                {
                    //check for document feeder
                    if ((Convert.ToUInt32(documentHandlingSelect.get_Value()) & WIA_DPS_DOCUMENT_HANDLING_SELECT.FEEDER) != 0)
                    {
                        hasMorePages = ((Convert.ToUInt32(documentHandlingStatus.get_Value()) & WIA_DPS_DOCUMENT_HANDLING_STATUS.FEED_READY) != 0);
                    }
                }

关于c# - 在 Windows 7 上使用 WIFI 扫描多个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60371387/

相关文章:

.net - 条形码扫描到网络浏览器的问题

c# - ForEach循环不改变类的属性

windows-7 - Clickonce 部署的应用程序是否仅为特定用户安装?

c++ - 如何在 CMake 中检查 Windows 版本?

css - 尝试在浏览器中使用Segoe字体

java - Java 中的开源虹膜扫描库

cocoa - 有没有用于图像扫描的cocoa框架?

c# - WebBrowser HtmlElement.GetAttribute ("href") 前置主机名

c# - WinForms 类似 iPad 的界面原型(prototype)设计应用程序

c# - 检查字符串类型到其他类型的转换