Private Declare Function GetDriveType Lib "kernel32" Alias _
"GetDriveTypeA" (ByVal nDrive As String) As Long
Private Const DRIVE_CDROM = 5
Public Function GetCDROMDriveLetter() As String
Dim DriveChar As Byte
Dim tmpDrive As String
GetCDROMDriveLetter = "Okänd"
On Error GoTo ErrorHandler
For DriveChar = 0 To 25
tmpDrive = Chr(65 + DriveChar) & ":\"
If (GetDriveType(tmpDrive) = DRIVE_CDROM) Then
GetCDROMDriveLetter = tmpDrive
Exit For
End If
Next DriveChar
ErrorHandler:
Exit Function
End Function
Private Sub Command1_Click()
MsgBox "CDROM Drive är : " & GetCDROMDriveLetter()
End Sub