Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to detect a mini Device storage (128kb)from inside of mi application?

Posted on 2004-08-16
4
198 Views
Last Modified: 2013-11-15
Hello I have those mini device storages 128kb and I need  to detect automatically from inside of my aplication and import data from it. Right now I use the drivelistbox to detect what letter, but my problem is when somebody don't know what letter is the mini device storage they try to select the others drives list in this combo drivelistbox but giving this as an error which I don't know how to filter that error.
Could somebody tell me how to detect this mini device storage automatically?
Thanks a lot
Daniel
0
Comment
Question by:danielmingolla
  • 3
4 Comments
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11807880
Try this (need reference to Microsoft Scripting Runtime)

Dim oFSO        As Scripting.FileSystemObject
Dim oDrive      As Scripting.Drive
Dim sType       As String
Dim sMsg        As String
   
    Set oFSO = New Scripting.FileSystemObject
   
    For Each oDrive In oFSO.Drives
        Select Case oDrive.DriveType
            Case 0: sType = "Unknown"
            Case 1: sType = "Removable"
            Case 2: sType = "Fixed"
            Case 3: sType = "Network"
            Case 4: sType = "CD-ROM"
            Case 5: sType = "RAM Disk"
        End Select

       
        sMsg = "Drive " & oDrive.DriveLetter & ": - " & sType
        If oDrive.IsReady Then
            sMsg = sMsg & " - Drive is Ready."
        Else
            sMsg = sMsg & " - Drive is not Ready."
        End If
       
        Debug.Print sMsg

    Next
   
    Set oFSO = Nothing

Drive should be ready, and it's type should be Removable. Also you should check oDrive.TotalSize. HTH
0
 

Author Comment

by:danielmingolla
ID: 11812748
Hello and thanks for your answer!!
Your sample looks like if what I need but is not working is not doing nothing I put all your code in a form in the load event and referenced to microsoft scripting but is not doing nothing neither the msgbox appear, could you please let me know what I am doing wrong!!
Thanks again
Daniel
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11812928
Private Sub Form_Load()
Dim oFSO        As Scripting.FileSystemObject
Dim oDrive      As Scripting.Drive
Dim sType       As String
Dim sMsg        As String
   
    Set oFSO = New Scripting.FileSystemObject
   
    For Each oDrive In oFSO.Drives
       
        If oDrive.IsReady Then
            If oDrive.DriveType = Removable And oDrive.TotalSize = 64274432 Then
                MsgBox oDrive.DriveLetter
            End If
        End If
       
    Next
   
    Set oFSO = Nothing
End Sub

64274432 is size of my USB flash device (64 MB). Replace this with size you need (128 MB = 64274432*2)
0
 
LVL 8

Accepted Solution

by:
mladenovicz earned 125 total points
ID: 11812946
Private Sub Form_Load()
Dim oFSO        As Scripting.FileSystemObject
Dim oDrive      As Scripting.Drive
Dim sType       As String
Dim sMsg        As String
Dim bFound      As Boolean
   
    Set oFSO = New Scripting.FileSystemObject
   
    For Each oDrive In oFSO.Drives
       
        If oDrive.IsReady Then
            If oDrive.DriveType = Removable And oDrive.TotalSize = 64274432 * 2 Then
                MsgBox oDrive.DriveLetter
                bFound = True
            End If
        End If
    Next
   
    If Not bFound Then MsgBox "Device can not be found"
   
    Set oFSO = Nothing
End Sub
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

809 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