I have an c# application that connects to the barcode scanners that are in HID mode by using the devices VendorID(VID) and ProductID(PID). Using the devices VID and PID we will construct the device path and they we will call the below code to create a Kernel object File so that we will get the handle to the device.
// Allocate a file object in the kernel, then return a handle to it. [DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)] protected extern static SafeFileHandle CreateFile(String DevicePath, uint dwDesiredAccess, System.IO.FileShare dwShareMode, IntPtr securityAttrs_MustBeZero, System.IO.FileMode dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile_MustBeZero);
The above code works for most of the Barcode scanners except the Zebra DS457 scanner The above line of code is throwing “The process cannot access the file because it is being used by another process. HRESULT 0x80070020” error only when trying to connect to the Zebra DS457 scanner. I am not sure why this is happening only for this scanner. Any suggestions on this is highly appreciated.
User contributions licensed under CC BY-SA 3.0