⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 VB源码,是初学者的福因.让你很快掌握VB编程
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   2370
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6405
   LinkTopic       =   "Form1"
   ScaleHeight     =   2370
   ScaleWidth      =   6405
   StartUpPosition =   3  '窗口缺省
   Begin MSComctlLib.ListView ListView1 
      Height          =   1935
      Left            =   0
      TabIndex        =   1
      Top             =   0
      Width           =   6375
      _ExtentX        =   11245
      _ExtentY        =   3413
      View            =   3
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FlatScrollBar   =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   0
   End
   Begin VB.CommandButton Command1 
      Caption         =   "显示驱动器"
      Height          =   375
      Left            =   2640
      TabIndex        =   0
      Top             =   1920
      Width           =   1095
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim drvtype(6) As String

Private Sub Command1_Click()
    On Error Resume Next
    Dim fso As New Scripting.FileSystemObject
    Dim drv As Scripting.Drive
    drvtype(0) = "未知"
    drvtype(1) = "软驱"
    drvtype(2) = "硬盘"
    drvtype(3) = "网络驱动器"
    drvtype(4) = "光驱"
    drvtype(5) = "虚盘"
    
    ListView1.ListItems.Clear
    
    tmpwidth = (ListView1.Width - 60) \ 24
    With ListView1.ColumnHeaders
        .Add , , "盘符", 3 * tmpwidth
        .Add , , "类型", 4 * tmpwidth
        .Add , , "文件系统", 4 * tmpwidth
        .Add , , "容量(KB)", 5 * tmpwidth
        .Add , , "可用(KB)", 5 * tmpwidth
        .Add , , "就绪", 3 * tmpwidth
    End With
    For Each drv In fso.drives
        With ListView1.ListItems.Add(, , drv.DriveLetter & ":")
            .SubItems(1) = drvtype(drv.drivetype)
            .SubItems(2) = drv.FileSystem
            .SubItems(3) = FormatNumber(drv.TotalSize / 1024, 0)
            .SubItems(4) = FormatNumber(drv.FreeSpace / 1024, 0)
            .SubItems(5) = IIf(drv.Isready, "Yes", "No")
        End With
    Next drv
    ListView1.Refresh
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -