📄 获得磁盘类型.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 2175
ClientLeft = 60
ClientTop = 345
ClientWidth = 3210
LinkTopic = "Form1"
ScaleHeight = 2175
ScaleWidth = 3210
StartUpPosition = 3 '窗口缺省
Begin VB.ListBox List1
Height = 1500
Left = 180
TabIndex = 0
Top = 510
Width = 2775
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "当前计算机上的磁盘:"
Height = 180
Left = 300
TabIndex = 1
Top = 150
Width = 1800
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Sub Form_Load()
Dim I As Integer
Dim Ret As Long '函数返回值
Dim DiskType As String '磁盘类型
For I = 65 To 90 '字符 A ~ Z 的 ASCII 码
DiskType = ""
Ret = GetDriveType(Chr$(I) & ":\") '传入磁盘代号
Select Case Ret
Case 2
DiskType = "软盘"
Case 3
DiskType = "硬盘"
Case 4
DiskType = "网路磁盘"
Case 5
DiskType = "光盘"
End Select
If DiskType <> "" Then List1.AddItem vbTab & Chr$(I) & ":\" & DiskType
Next I
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -