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:
Dim filesys Dim l As Integer Dim CurrentDriveLetter As String Dim j As Integer Dim TempString As String Dim CharCheck As String For l = 0 To Drive1.ListCount TempString = Trim(Drive1.List(l)) CurrentDriveLetter = "" For j = 1 To Len(TempString) CharCheck = Mid$(TempString, j, 1) If Mid$(TempString, j, 1) <> ":" Then CurrentDriveLetter = CurrentDriveLetter + CharCheck Else CurrentDriveLetter = CurrentDriveLetter + CharCheck Exit For End If Next If CurrentDriveLetter <> "" Then Set filesys = CreateObject("Scripting.FileSystemObject") Set drv = filesys.GetDrive(CurrentDriveLetter) Select Case drv.DriveType Case 0: drtype = "Unknown" Case 1: drtype = "Removable" Case 2: drtype = "Fixed" Case 3: drtype = "Network" Case 4: drtype = "CD-ROM" Case 5: drtype = "RAM Disk" End Select If drtype = "CD-ROM" Then MsgBox "The specified drive is a " & drtype & " type disk." End If End If Next


Reply With Quote