Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
557 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...