Click here to Skip to main content
15,867,780 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,

We have developed some application with Biometric USB device to login in windows application. It works perfectly except device hang issue. After so many attempts or can say with in 15 days interval, device got stuck and only work after Reinsert.

We tried to solve but still it comes sometimes on any machines. So we are looking some other way to disconnect/connect through programatically on refresh button.

Biometric device doesn't show as "Drive" on hard disk and its having storage capacity as well.

Thanks in advance...!

What I have tried:

Tried some piece of code as well as tried via registry settings as well but hard luck.
Posted
Updated 21-Aug-18 0:01am
Comments
[no name] 21-Aug-18 5:30am    
Do you use maybe usbser.sys to control the usb device?
Ramshri 22-Sep-18 23:50pm    
Close the handle after everytime you read the fingerprint and call init method before everytime capturing the fingerprint. Share if it works

1 solution

The methods from this solution will use C APIs. So you would have to use PInvoke with C#.

The cleanest method would be using a device specific API library that provides a reset call. Such libraries are usually provided as part of an SDK. Check if such an SDK is provided for your device by searching the web or contacting the manufacturer. If so, check if it provides a reset function. Such APIs provide usually also a function to find present devices.

For the other methods you have first to identify the device or the USB hub to which it is connected. Note also that these require administrator priviliges.

For most of the other methods you have to use the Windows SetupAPI. The article Hardware Helper Library for C#[^] and the sources may be helpful.

The first task is to identify the device(s) using one of the SetupAPI enumeration functions. If you want to acces the device itself you can get the device GUID from the INF installation file. To enumerate the hubs use the GUID_DEVINTERFACE_USB_HUB.

Having enumerated the USB hubs, you can for each enumerate the childs (which may be also hubs) until you find your device. Then you can use the CM_Disable_DevNode function | Microsoft Docs[^] and CM_Enable_DevNode function | Microsoft Docs[^] to try getting the device into a proper state again. Note that this might not work with all devices and Windows versions.

Finally you can go low level and use the LibUsbDotNet C# USB Library download | SourceForge.net[^]. This allwos you to toggle (disable and enable again) the USB hubs and ports which results in the connected devices to be removed and inserted again.
 
Share this answer
 
Comments
Freelancers 21-Aug-18 7:20am    
@Jochen - Thanks for the suggestion but just I tried the article with Win7/Win8/Win10 Operating system, it doesnot work. It doesnt show any thing.
Jochen Arndt 21-Aug-18 7:46am    
The artcile is rather old and was only meant for reading. But using the SeupAPI with PInvoke should work even with Windows 10.

Have you checked for an SDK? That is the preferred method.

Any other method requires a lot of reading, understanding how it works, and testing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900