【问题标题】:Identify scanner(s) attached to the computer?识别连接到计算机的扫描仪?
【发布时间】:2010-10-06 13:32:37
【问题描述】:

我正在处理的应用程序正在使用扫描仪,它可能属于几种类型之一。我需要识别附加的扫描仪,提供从附加的扫描仪中选择默认扫描仪的选项,并在需要时更改此选择。到目前为止,我想出了这个解决方案:

ManagementObjectSearcher search = new System.Management.ManagementObjectSearcher("SELECT * From Win32_PnPEntity");

ManagementObjectCollection deviceCollection = search.Get();

foreach (ManagementObject info in deviceCollection)
{
    string deviceName = Convert.ToString(info["Caption"]);

    if( /* check something about deviceName */)
    {
        // add a scanner to the list
    }
}

这对我有用,因为我知道在 info["Caption"] 中会发生什么。 但是,有几个问题:

  • 我知道我的设备将位于“成像设备”下。有没有办法只识别“成像设备”分支的成员,而不遍历每个 PnP 设备?刚刚发现在我的 PC 上 deviceCollection 有 190 个条目。将它过滤到只有一对会非常好。 :)
  • 对于我事先不知道要连接的扫描仪型号/类型的情况,有没有办法识别该设备是扫描仪?

【问题讨论】:

    标签: .net windows upnp image-scanner


    【解决方案1】:

    您可以按照this thread 中的建议尝试 Windows 图像采集自动化库

    【讨论】:

    • 这种方法在编译和运行方面“有效”,但 manager.DeviceInfos.Count 为 0。我会继续寻找发生这种情况的原因。
    • 我想我应该接受这个答案,因为它应该可以工作......我不知道为什么它不 - 可能设备驱动程序不支持 WIA (???)
    猜你喜欢
    • 2010-11-23
    • 1970-01-01
    • 2012-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-17
    相关资源
    最近更新 更多