-
February 18th, 2008, 09:09 AM
#1
Identification of USB flash disk in VB6
Hi all!
I need help in VB6 under Win XP. I need to read VID and PID of my USB flash disk in VB6. I googled many examples but nothing works
My disk is connected for example as drive "I:\" and by some utilities I found that it has both VID and PID. How to read this information in VB6?
I need something easy like:
Code:
dim VID
dim PID
sub GetVIDandPID(Path as string)
...??? something to get VID and PID ???...
end sub
sub main()
GetVIDandPID "I:\"
msgbox VID & " " & PID
end sub
I will be very happy if anybody knows some method which WORKS!
Thanks a lot.
Last edited by PeejAvery; February 18th, 2008 at 10:50 AM.
Reason: Added code tags.
-
February 18th, 2008, 10:58 AM
#2
Re: Identification of USB flash disk in VB6
Well, it is stored in the registry. All you need to do is parse the string out of the key.
HKEY_CURRENT_CONFIG\System\CurrentControlSet\Enum\USBSTOR
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
February 19th, 2008, 01:21 AM
#3
Re: Identification of USB flash disk in VB6
But I need to detect if disc specified by VID and PID is connected now or not... I dont want to read info from registry but from the disk.
Any idea?
-
February 19th, 2008, 02:04 AM
#4
Re: Identification of USB flash disk in VB6
How does the disk know? It doesn't have that info.
-
February 19th, 2008, 02:36 AM
#5
Re: Identification of USB flash disk in VB6
But if VID and PID are both hardware dependent and unique so it must be stored "on disk". Is not it? So for example how can I read VID and PID from disk "H:\"? (I know that it is USB disk)
-
February 19th, 2008, 02:40 AM
#6
Re: Identification of USB flash disk in VB6
Why not just read from the registry? You can use this API:
Code:
Option Explicit
Private Const DRIVE_UNKNOWN = 0
Private Const DRIVE_ABSENT = 1
Private Const DRIVE_REMOVABLE = 2
Private Const DRIVE_FIXED = 3
Private Const DRIVE_REMOTE = 4 'Network drive
Private Const DRIVE_CDROM = 5
Private Const DRIVE_RAMDISK = 6
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" _
(ByVal nDrive As String) As Long
Dim DriveLetter As String
Private Function TestDrive(ByVal strDrive As String) As Boolean
If GetDriveType(strDrive) = 4 Then
TestDrive = True
Else
TestDrive = False
End If
End Function
Private Sub Command1_Click()
Dim drivetype As Integer
Dim typemsg As String
drivetype = (GetDriveType(DriveLetter))
Select Case drivetype
Case 0
typemsg = "DRIVE_UNKNOWN"
Case 1
typemsg = "DRIVE_ABSENT"
Case 2
typemsg = "DRIVE_REMOVABLE"
Case 3
typemsg = "DRIVE_FIXED"
Case 4
typemsg = "DRIVE_REMOTE / Network Drive"
Case 5
typemsg = "DRIVE_CDROM"
Case 6
typemsg = "DRIVE_RAMDISK?"
End Select
MsgBox "Drive " & UCase(DriveLetter) & "\ = " & typemsg
End Sub
Private Sub Drive1_Change()
DriveLetter = Drive1.Drive
End Sub
Private Sub Form_Load()
DriveLetter = Drive1.Drive
End Sub
But it is just REMOVEABLE
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|