СообЧа > База Знаний > Программирование > Visual Basic

Вопрос

Как узнать букву CD-ROM'а?

Ответ

Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias
"GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As
Long
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal
nDrive As String) As Long
Function GetCDROMs() As String()
   Dim CDROMs() As String
   ReDim CDROMs(0) As String
   Dim strSave As String
   strSave = String(255, Chr$(0))
   ret& = GetLogicalDriveStrings(255, strSave)
   For keer = 1 To 100
       If Left$(strSave, InStr(1, strSave, Chr$(0))) = Chr$(0) Then Exit For
       If GetDriveType(Left$(strSave, InStr(1, strSave, Chr$(0)) — 1)) = 5 Then
        ReDim Preserve CDROMs(UBound(CDROMs) + 1) As String
        CDROMs(UBound(CDROMs)) = Left$(strSave, InStr(1, strSave, Chr$(0)) — 1)
       End If
       strSave = Right$(strSave, Len(strSave) — InStr(1, strSave, Chr$(0)))
     Next keer
     GetCDROMs = CDROMs
End Function

Private Sub Form_Load()
  Me.AutoRedraw = True
  Me.Print Join(GetCDROMs, vbCrLf)
End Sub

Хвастунов Михаил



Copyright © 2000-2004 Сообщество Чайников
Контактная информация