USB device being in use
-
I know there is a way to tell if the usb device is in use. When one application fetches one usb device, the other application is unable to get the same device handle because it already "taken" by the 1st application. right now, my two application are able to get the same usb devices. any suggestion on how to prevent the 2nd application from detecting or open the usb device that is already taken by the other application?
-
I know there is a way to tell if the usb device is in use. When one application fetches one usb device, the other application is unable to get the same device handle because it already "taken" by the 1st application. right now, my two application are able to get the same usb devices. any suggestion on how to prevent the 2nd application from detecting or open the usb device that is already taken by the other application?
-
Use a "Mutex". Before "taking" the usb device, each application tries to create a Mutex. If the Mutex is created, the device was free; else the "other" app is using the device (because "it" has already created the Mutex).
hmm I don't think Mutex would do. Tried to understand Mutex. but what about with this method?
DeviceHandle = CreateFile(DevicePath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, ref Security, OPEN_EXISTING, 0, 0);
Tried to understand it a bit too. If I use 0 in place of FILE_SHARE_READ | FILE_SHARE_WRITE, would this be a good idea?
-
hmm I don't think Mutex would do. Tried to understand Mutex. but what about with this method?
DeviceHandle = CreateFile(DevicePath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, ref Security, OPEN_EXISTING, 0, 0);
Tried to understand it a bit too. If I use 0 in place of FILE_SHARE_READ | FILE_SHARE_WRITE, would this be a good idea?