Option Explicit
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal ndrive As String) As Long
Private Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpsectorspercluster As Long, lpbytespersector As Long, lpnumberoffreeclusters As Long, lptotalnumberofclusters As Long) As Long
Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, ByVal lpVolumeSerialNumber As Long, ByVal lpMaximumComponentLength As Long, ByVal lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Private Sub Drive1_Change()
  On Error Resume Next:
  Dim a, b, c, d, s As Long
  Dim e, f As String * 10
  Dim h, i, j, k, l, m As Long
  m = GetVolumeInformation(Drive1.Drive + "\", e, 255, i, j, k, f, 255)
  s = GetDiskFreeSpace(Drive1.Drive + "\", a, b, c, d)
    Select Case GetDriveType(Drive1.Drive)
      Case 1, 3:
        If s <> 0 And m <> 0 Then
          Label1.Caption = "该驱动为硬盘" + Chr(13) + Chr(10) + "总空间为" + Format$((a * b * d / 1024 / 1024 / 1024), "###.##") + "G" + Chr(13) + Chr(10) + "剩余空间" + Format$((a * b * c / 1024 / 1024 / 1024), "###.##") + "G" + Chr(13) + Chr(10) + "磁盘格式为" + f
        End If
      Case 2: Label1.Caption = "该驱动为软驱" + Chr(13) + Chr(10) + "总空间为" + Format$((a * b * d / 1024 / 1024), "###.##") + "M" + Chr(13) + Chr(10) + "剩余空间" + Format$((a * b * c / 1024 / 1024), "###.##") + "M"
      Case 4: Label1.Caption = "该驱动为网络驱动器" + Chr(13) + Chr(10) + "总空间为" + Format$((a * b * d / 1024 / 1024 / 1024), "###.##") + "G" + Chr(13) + Chr(10) + "剩余空间" + Format$((a * b * c / 1024 / 1024 / 1024), "###.##") + "G" + Chr(13) + Chr(10) + "磁盘格式为" + f
      Case 5: Label1.Caption = "该驱动为光驱" + Chr(13) + Chr(10) + "总空间为" + Format$((a * b * d / 1024 / 1024), "0.00") + "M" + Chr(13) + Chr(10) + "剩余空间" + "0M" + Chr(13) + Chr(10) + "磁盘格式为" + f
      Case 6: Label1.Caption = "该驱动为RAM驱动器" + Chr(13) + Chr(10) + "总空间为" + Format$((a * b * d / 1024 / 1024 / 1024), "###.##") + "G" + Chr(13) + Chr(10) + "剩余空间" + Format$((a * b * c / 1024 / 1024 / 1024), "###.##") + "G" + Chr(13) + Chr(10) + "磁盘格式为" + f
    End Select
End SubPrivate Sub Form_Load()
  Drive1_Change
End Sub
这是我以前编的一个程序,希望对你有所帮助!