Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/03/2008, 11:04
opermty
Usuario no validado
 
Fecha de Ingreso: mayo-2006
Mensajes: 42
Antigüedad: 18 años
Puntos: 0
Re: Reconocer, leer y escribir dispositivo USB

Por API para saber el tipo de unidad:

Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Sub Form_Load()
Me.AutoRedraw = True
'Get information about the C:\
Select Case GetDriveType("C:\")
Case 2
Me.Print "Removable"
Case 3
Me.Print "Drive Fixed"
Case Is = 4
Me.Print "Remote"
Case Is = 5
Me.Print "Cd-Rom"
Case Is = 6
Me.Print "Ram disk"
Case Else
Me.Print "Unrecognized"
End Select
End Sub


Por script -------------------------------------------------------

Function MostrarTipoUnidad(rutaUnidad)
Dim fso, d, t
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(rutaUnidad)
Select Case d.DriveType
Case 0: t = "Desconocido"
Case 1: t = "Extraíble"
Case 2: t = "Fijo"
Case 3: t = "Red"
Case 4: t = "CD-ROM"
Case 5: t = "Disco RAM"
End Select
MostrarTipoUnidad = "Unidad " & d.DriveLetter & ": - " & t
End Function




Para listar las unidades por script --------------------------------------------

Function MostrarListaUnidades
Dim fso, d, dc, s, n
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
n = ""
s = s & d.DriveLetter & " - "
If d.DriveType = 3 Then
n = d.ShareName
ElseIf d.IsReady Then
n = d.VolumeName
End If
s = s & n & "<BR>"
Next
MostrarListaUnidades = s
End Function