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
    Posts
    11
    Reputation
    114

    USB interrupt

    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

  2. #2
    JuggaloBrotha's Avatar
    JuggaloBrotha is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Jun 2004
    Location
    Lansing, MI; USA
    Posts
    4,364
    Reputation
    978
    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:
    Code:
    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
    Posts
    1
    Reputation
    0
    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.

  4. #4
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,624
    Reputation
    2739
    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.

Bookmarks

Posting Permissions

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