Listing A


Private Fs As New Scripting.FileSystemObject

Private Drv As Drive, Drvs As Drives
 

Private Sub cboDrives_Click()

    Dim sDrv As String

    Dim CurrDrv As Drive
  

    CleanAll
  

    sDrv = Left(cboDrives.Text, 1)

    For Each Drv In Drvs

        If Drv.DriveLetter = sDrv Then

            Set CurrDrv = Drv

            Exit For

        End If

    Next
  

   Call GetDriveInfo(CurrDrv)

End Sub
 

Private Sub CleanAll()

    Dim cntl As Control

    For Each cntl In frmInfo

        If TypeOf cntl Is TextBox Then

            cntl.Text = ""

        End If

    Next

End Sub
 

Private Sub GetDriveInfo(ByVal CurrDrv As Drive)

    Dim sDriveType As String
  

    On Error GoTo GetDriveInfo_Eh
 

    With CurrDrv

        Select Case .DriveType

            Case 0

                sDriveType = "Unknown"

            Case 1

                sDriveType = "Removable"

            Case 2

                sDriveType = "Fixed"

            Case 3

                sDriveType = "Remote"

            Case 4

                sDriveType = "CDRom"

            Case 5

                sDriveType = "RamDisk"

        End Select

        txtDriveType.Text = sDriveType

        txtSerialNumber.Text = .SerialNumber

        txtAvailableSpace.Text = .AvailableSpace

        txtFileSystem.Text = .FileSystem

        txtFreeSpace.Text = .FreeSpace

        txtTotalSize.Text = .TotalSize

    End With
 

GetDriveInfo_Exit:

    Exit Sub

GetDriveInfo_Eh:

    Select Case Err.Number

        Case 71 ' drive A not ready (empty)

            Resume Next

        Case Else

            Dim sMsg As String

            sMsg = "Error Number: " & Err.Number & vbCrLf & "Error Description: " & Err.Description

            MsgBox sMsg

            Resume GetDriveInfo_Exit

    End Select

End Sub
 

Private Sub Form_Load()

    Dim s As String, n As String, sOS As String
  

    On Error GoTo FormLoad_Eh

      
    Set Drvs = Fs.Drives
  

    For Each Drv In Drvs

        s = ""

        s = Drv.DriveLetter & " - "

        If Drv.DriveType = 3 Then

            n = Drv.ShareName

        Else

            n = Drv.VolumeName

        End If

        cboDrives.AddItem s & n

    Next

    cboDrives.ListIndex = 0
 

   With SysInfo1

        Select Case .OSPlatform

            Case 0

                sOS = "Unidentified"

            Case 1

                sOS = "Windows 95, version " & _

                    CStr(.OSVersion) & "(" & _

                   CStr(.OSBuild) & ")"

            Case 2

                sOS = "Windows NT, version " & _

                    CStr(.OSVersion) & "(" & _

                    CStr(.OSBuild) & ")"

        End Select

    End With

    lblOS = lblOS.Caption & Space(2) & sOS
 

FormLoad_Exit:

    Exit Sub
 

FormLoad_Eh:

    Select Case Err.Number

    Case 71 ' drive A not ready (empty)

        Resume Next

    Case Else

        Dim sMsg As String

        sMsg = "Error Number: " & Err.Number & vbCrLf & "Error Description: " & Err.Description

        MsgBox sMsg

        Resume FormLoad_Exit

    End Select

End Sub
 

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

    Unload Me

End Sub
 

Private Sub Form_Unload(Cancel As Integer)

    Set frmInfo = Nothing

End Sub