Public Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long Public Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long Public Declare Function GetLogicalDrives Lib "kernel32" () As Long
'VARIABLE QUE VA A TOMAR EL MOMBRE DE LA UNIDAD Public UnidadUSB As String
Public Function GetDriveSerial(ByVal sDrive As String) As Long sDrive = UCase(Left$(sDrive, 1)) & ":\" Call GetVolumeInformation(sDrive, vbNullString, 0, GetDriveSerial, 0, 0, vbNullString, 0) UnidadUSB = sDrive End Function
Public Function IsConnected(ByVal lID As Long) As Boolean Dim LDs As Long, Cnt As Long, sDrives As String LDs = GetLogicalDrives For Cnt = 0 To 25 If (LDs And 2 ^ Cnt) <> 0 Then sDrives = sDrives + Chr$(65 + Cnt) If GetDriveType(Trim(Right(sDrives, 1) & ":\")) = 2 Then UnidadUSB = Trim(Right(sDrives, 1) & ":\") End If End If Next Cnt End Function
hay tienes un modulo para dectectar usb espero que te sirva, saludos
|