Find out which process has an exclusive lock on a USB device handle

后端 未结 4 1969
死守一世寂寞
死守一世寂寞 2021-01-12 11:02

I have a library that reads/writes to a USB-device using CreateFile() API. The device happens to implement the HID-device profile, such that it\'s compatible with Microsoft\

4条回答
  •  攒了一身酷
    2021-01-12 11:56

    This is what I use to read from a Magtek card reader:

    //Open file on the device
    deviceHandle = 
        CreateFile (deviceDetail->DevicePath, 
        GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 
        NULL, OPEN_EXISTING, 0, NULL);
    

    Try those options and see if you can at least read from the device.

    I understand your pain here... I found the USB HID documentation to be basically wrong in several places.

    [Edit] There's not much out there on this problem. Here's a codeproject link that lightly touches on the subject in a thread at the bottom. Sounds like maybe if it's a keyboard or mouse windows grabs it exclusively.

提交回复
热议问题