3

我正在使用 WIA 连接到扫描仪。我枚举设备信息,然后尝试连接到设备。我不断收到异常。

HRESULT 异常:0x80210006

我在 WPF 窗口后面的代码中调用代码。

        DeviceManager manager = new DeviceManagerClass();
        DeviceInfo device = null;
        foreach (DeviceInfo deviceInfo  in manager.DeviceInfos)
        {
            var ID = deviceInfo.DeviceID;
            var props = deviceInfo.Properties ;
            foreach (Property property in props)
            {
                var name = property.Name;
                var descr = property.get_Value() as string;
            }
            var type = deviceInfo.Type;
            if (type == WiaDeviceType.ScannerDeviceType)
                device = deviceInfo;
        }
        if (device != null)
              device.Connect();

我无法弄清楚为什么会这样。任何帮助,将不胜感激。

4

1 回答 1

2

HRESULT: 0x80210006WIA_ERROR_BUSY

WIA API 错误代码页面

WIA_ERROR_BUSY        The WIA device is busy.

根据Communicating with a WIA Device in Multiple Threads or Applications,看起来其他东西可能正在访问该设备:

If a thread currently has a device locked (it is actively communicating with that device) and another thread attempts to call a method that actively communicates with the device, the method returns a WIA_ERROR_BUSY error.

于 2013-04-02T19:17:44.410 回答