Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const CB_DELETESTRING = &H144
Private Const DRIVE_CDROM = 5
Private Sub FilterDriveListBox(DriveLB As DriveListBox, Optional NewSelIndex As Long = -1)
Dim i As Integer
Dim nDrive As String
For i = 1 To DriveLB.ListCount Step 1
nDrive = Chr(i + 64) & ":\"
If (GetDriveType(nDrive) <> DRIVE_CDROM) Then
SendMessage DriveLB.hwnd, CB_DELETESTRING, 0, i - 1
End If
Next
If (DriveLB.ListCount > NewSelIndex And NewSelIndex >= 0) Then DriveLB.ListIndex = NewSelIndex
End Sub
Private Sub Form_Load()
Call FilterDriveListBox(Drive1, 0)
End Sub