可以用来做批量扫描的类

这几天帮同事解决一个连接扫描仪的问题,查阅了一下WIA的资料,写了一个类,比较简单,共享出来,方便大家来写扫描的组件。

这个类需要windows的WIA组件支持,具体内容我都放到附加的代码中了。

 

using System;
using System.Collections.Generic;
using System.Text;
using WIA;

namespace Scaner
{
    public class Scanner
    {
        public ImageFile Scan()
        {
            DeviceManager manager = new DeviceManager();
            Device device = null;
            foreach (DeviceInfo info in manager.DeviceInfos)
            {
                if (info.Type != WiaDeviceType.ScannerDeviceType) continue;
                device = info.Connect();
                break;
            }
            Item item = device.Items[1];
            CommonDialog cdc = new WIA.CommonDialog();
            ImageFile imageFile = cdc.ShowTransfer(item,
                "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}",
                true) as ImageFile;
            return imageFile;
        }
    }
}


https://files.cnblogs.com/wengyuli/ScanApp.rar

posted @ 2012-01-03 16:25  翁玉礼  阅读(1031)  评论(2编辑  收藏  举报