识别连接到计算机的扫描仪?

时间:2009-02-10 02:27:41

标签: .net windows upnp image-scanner

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

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
    }
}

这对我有用,因为我知道在信息[“标题”]中会发生什么。 但是,有几个问题:

  • 我知道我的设备将在“成像设备”之下。有没有办法只识别“成像设备”分支的成员,而无需遍历每个PnP设备?刚发现在我的电脑上,deviceCollection有190个条目。将它过滤到一对夫妇真的很不错。 :)
  • 有没有办法确定设备是扫描仪,对于我事先不知道将要连接的扫描仪型号/类型的情况?

1 个答案:

答案 0 :(得分:2)

您可以按照this thread

中的建议尝试Windows Image Acquisition Automation Library