Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
569 views
in Technique[技术] by (71.8m points)

kernel - "The process cannot access the file because it is being used by another process.HRESULT0x80070020”. Error Connecting to Barcode Scanner using c# app

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.

question from:https://stackoverflow.com/questions/65933094/the-process-cannot-access-the-file-because-it-is-being-used-by-another-process

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...