Solved

Detect USB Pen Drives

Posted on 2004-10-17
6
838 Views
Last Modified: 2008-01-09
Hi

Is it possible in vb to detect any USB Pen drives attached to the computer?

Thanks
Adam
0
Comment
Question by:adam_pedley
  • 3
  • 2
6 Comments
 
LVL 34

Expert Comment

by:flavo
ID: 12335581
0
 
LVL 4

Author Comment

by:adam_pedley
ID: 12335629
Thanks

but how do i scan already existing drives to find a flash drive, i cant always depend that my program will be loaded before the flash drive is plugged in
0
 
LVL 18

Accepted Solution

by:
armoghan earned 500 total points
ID: 12345507
Get all drives and iterate through all the derive types and see there type

see the following links for device type
http://www.codeproject.com/csharp/bienzsysinfo.asp
http://custom.programming-in.net/articles/art9-1.asp?f=GetDriveType
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 18

Expert Comment

by:armoghan
ID: 12345516
This is how you can get all the drives
http://www.csharphelp.com/archives2/archive363.html
0
 
LVL 4

Author Comment

by:adam_pedley
ID: 12345584
Thanks

Here is the final code I came up with that detects all drives and finds out what type they are


    Public Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Integer

    Private Sub Detect_Drives()
        txtDrives.Clear()
        Try
            Dim str() As String = Directory.GetLogicalDrives()
            Dim i As Integer = 0
            While i < str.Length
                txtDrives.AppendText(str(i) & "     " & GetDriveType(str(i)) & vbCrLf)
                i += 1
            End While
        Catch ex As IOException
            MsgBox(ex.Message)
        End Try
End Sub
0
 
LVL 4

Author Comment

by:adam_pedley
ID: 12345599
Also remember to import

imports system.io

One error i did find is that the site http://custom.programming-in.net/articles/art9-1.asp?f=GetDriveType thinks flash drives are type # 6 but all my flash drives come back as type # 2

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now