Results 1 to 4 of 4

Thread: USB interrupt

  1. #1
    raghava is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Sep 2005

    USB interrupt

    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.

  2. #2
    JuggaloBrotha's Avatar
    JuggaloBrotha is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Jun 2004
    Lansing, MI; USA
    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:
    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
    Currently using: VS 2010 Ultimate on Win7 Ultimate x64.

  3. #3
    zeeshan.elahi is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Oct 2009

    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

    Thanks in advance.

  4. #4
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2005
    Monitoring a Smartcard Reader « Geers’ Blog
    Do take notice that VB.Net Forums is for VB.Net related inquiries only. In this case it it simply means that you don't have to convert the code.
    How to format posts with code blocks etc - present the problem/post properly

    Visual Studio Community 2017


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts