USB interrupt

raghava

Member
Joined
Sep 17, 2005
Messages
11
Programming Experience
1-3
hi
is there any way to handle interrupts in a USB device.
my problem is ....
I have a usb smart card reader which authenticates the user of my system.
I need to notice the insertions and removals of the smart card to and from the reader.

any body pls help.
thanks in advance.
Raghava
 
the only way that i know of is:

when the user inserts a flash card or plugs in a flash drive the OS gives it a logical drive (listed in My Computer)

so what i do is when the app starts (the flash drive needs to be un-pluged) it grabs a list of all the current logical drives and stores them in a string array

then i have a timer that every 300 miliseconds it gets a list of all the logical drives and stores them in a new string array variable then compairs the two and if it produces a -1 (meaning theres a drive in the new variable that's not in the original one, meaning the user plugged in a flash drive)

which means i know what the drive letter is for that flash drive too and i store that in a different variable, here's the code i use:
VB.NET:
Private strDrives() As String = Environment.GetLogicalDrives
Private strFlashDrive As String

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        tmrDrives.Enabled = True
    End Sub

    Private Sub tmrDrives_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrDrives.Tick
        Dim CurrentDrives() As String = Environment.GetLogicalDrives
        For Each Drive As String In CurrentDrives
            If strDrives.IndexOf(strDrives, Drive) = -1 Then
                tmrDrives.Enabled = False
                strFlashDrive = Drive
            End If
        Next Drive
    End Sub
 
Raghava,

Did you find the solution to your problem? I Run in to same problem can you please help out to solve this problem that how to detect insertion and removal of smart card from reader? I am using ACR38 reader and 3.5 C#.net



Thanks in advance.
 
Back
Top