[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-08-16
4
Medium Priority
?
206 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 500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is an update and follow-up of my previous article:   Storage 101: common concepts in the IT enterprise storage This time, I expand on more frequently used storage concepts.
Windows Server 2003 introduced persistent Volume Shadow Copies and made 2003 a must-do upgrade.  Since then, it's been a must-implement feature for all servers doing any kind of file sharing.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

873 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