Alle Laufwerke ermitteln
[Windows 95/98/NT/2000]

25.08.1998


Alle Laufwerke ermitteln - hiermit können Sie feststellen,
    welches Laufwerk eine Festplatte, CD-ROM, Netzlaufwerk usw. ist.

ERFORDERLICHE OBJEKTE
1 Commandbutton (Command1)

 FORM-CODE
   Private Declare Function GetDriveType Lib "Kernel32" Alias _
      "GetDriveTypeA" (ByVal nDrive As String) As Long
   Private Declare Function GetLogicalDriveStrings Lib "Kernel32" _
      Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, _
      ByVal lpBuffer As String) As Long
   Private Const DRIVE_REMOVABLE = 2
   Private Const DRIVE_FIXED = 3
   Private Const DRIVE_REMOTE = 4
   Private Const DRIVE_CDROM = 5
   Private Const DRIVE_RAMDISK = 6
   Private Sub Command1_Click()
      Dim r&, alleDrvs$, drv$, pos%, drvtyp&
      Dim CDfound As Integer
      alleDrvs$ = Space$(64)
      r& = GetLogicalDriveStrings(Len(alleDrvs$), alleDrvs$)
      alleDrvs$ = Left$(alleDrvs$, r&)
      Do
         pos% = InStr(alleDrvs$, Chr$(0))
         If pos% Then
            drv$ = Left$(alleDrvs$, pos%)
            alleDrvs$ = Mid$(alleDrvs$, pos% + 1, Len(alleDrvs$))
            drvtyp& = GetDriveType(drv$)
            Select Case drvtyp&
               Case 2
                  t = "Wechseldatenträger"
               Case 3
                  t = "Festplatte"
               Case 4
                  t = "Netzlaufwerk"
               Case 5
                  t = "CD-ROM"
               Case 6
                  t = "RAM-Disk"
            End Select
            Print Mid(drv$, 1, 2) & vbTab & " " & t
         End If
      Loop Until alleDrvs$ = ""
   End Sub

 

Download - 2 KB