可以用来做批量扫描的类

这几天帮同事解决一个连接扫描仪的问题,查阅了一下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 @   翁玉礼  阅读(1041)  评论(2编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
点击右上角即可分享
微信分享提示