Results 1 to 1 of 1

Thread: For anyone trying to find the CD-ROM

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Location
    Atlanta, GA
    Posts
    177

    For anyone trying to find the CD-ROM

    I was looking for some code that would allow me to find the CD-ROM on any computer regaurdless of the drive letter. I found bit's and pieces of code, but none did exactly that. So this is what I came up with. I hope it helps someone.

    VB Code:
    1. Dim filesys
    2. Dim l As Integer
    3. Dim CurrentDriveLetter As String
    4. Dim j As Integer
    5. Dim TempString As String
    6. Dim CharCheck As String
    7.  
    8. For l = 0 To Drive1.ListCount
    9.   TempString = Trim(Drive1.List(l))
    10.   CurrentDriveLetter = ""
    11.   For j = 1 To Len(TempString)
    12.           CharCheck = Mid$(TempString, j, 1)
    13.             If Mid$(TempString, j, 1) <> ":" Then
    14.                CurrentDriveLetter = CurrentDriveLetter + CharCheck
    15.             Else
    16.                CurrentDriveLetter = CurrentDriveLetter + CharCheck
    17.                Exit For
    18.             End If
    19.   Next
    20.   If CurrentDriveLetter <> "" Then
    21.   Set filesys = CreateObject("Scripting.FileSystemObject")
    22.   Set drv = filesys.GetDrive(CurrentDriveLetter)
    23.   Select Case drv.DriveType
    24.      Case 0: drtype = "Unknown"
    25.      Case 1: drtype = "Removable"
    26.      Case 2: drtype = "Fixed"
    27.      Case 3: drtype = "Network"
    28.      Case 4: drtype = "CD-ROM"
    29.      Case 5: drtype = "RAM Disk"
    30.   End Select
    31.    If drtype = "CD-ROM" Then
    32.      MsgBox "The specified drive is a " & drtype & " type disk."
    33.    End If
    34.   End If
    35. Next
    Last edited by MartinLiss; Jan 21st, 2005 at 05:55 PM. Reason: Added VBCode tags
    212 will lead you to the truth

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width