Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect which drive letter is smartmedia card reader? 2

Status
Not open for further replies.

threedim

Technical User
Mar 18, 2002
22
MY
How do I detect which drive letter is the smartmedia card reader in vb?
 
use getlogicaldrivestrings to return all root paths


use getdrivetype to get drives type


good luck!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
 
ok... i got bored...

heres some code:-

Code:
Option Explicit

Private Declare Function GetLogicalDriveStrings Lib "kernel32" _
    Alias "GetLogicalDriveStringsA" ( _
        ByVal nBufferLength As Long, _
        ByVal lpBuffer As String _
) As Long

Private Declare Function GetDriveType Lib "kernel32" _
    Alias "GetDriveTypeA" ( _
        ByVal nDrive As String _
) As Long

Private Const DRIVE_CDROM = 5
Private Const DRIVE_FIXED = 3
Private Const DRIVE_RAMDISK = 6
Private Const DRIVE_REMOTE = 4
Private Const DRIVE_REMOVABLE = 2


Private Sub Command1_Click()
    
    Dim myLength As Integer
    Dim myBuffer As String
    Dim i As Integer
    Dim myDrive As String
    Dim myType As Long
    
    myLength = GetLogicalDriveStrings(0, 0)
    myBuffer = String$(myLength, 0)
    myLength = GetLogicalDriveStrings(myLength, myBuffer)
    For i = 1 To Len(myBuffer) - 1 Step 4
        myDrive = Mid$(myBuffer, i, 3)
        myType = GetDriveType(myDrive)
        Select Case myType
            Case DRIVE_CDROM
                MsgBox myDrive & " is a CD-Rom Drive", _
                    vbOKOnly + vbInformation, _
                    "Your Drives"
            Case DRIVE_FIXED
                MsgBox myDrive & " is a Fixed Drive", _
                    vbOKOnly + vbInformation, _
                    "Your Drives"
            Case DRIVE_RAMDISK
                MsgBox myDrive & " is a Ram Disk", _
                    vbOKOnly + vbInformation, _
                    "Your Drives"
            Case DRIVE_REMOTE
                MsgBox myDrive & " is a Remote Drive", _
                    vbOKOnly + vbInformation, _
                    "Your Drives"
            Case DRIVE_REMOVABLE
                MsgBox myDrive & " is a Removable Drive", _
                    vbOKOnly + vbInformation, _
                    "Your Drives"
            Case Else
                MsgBox "The following drive " & CStr(myDrive) & " is not recognised.", _
                    vbOKOnly + vbCritical, _
                    "Your Drives"
        End Select
    Next
    
End Sub

hope it helps!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
 
That is great. exactly what i was looking for. Thanks! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top