vb检查磁盘类型
发布时间:2020-12-17 08:04:08 所属栏目:百科 来源:网络整理
导读:Option Explicit Private Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long Private Sub Command1_Click() Select Case GetDriveType("C:") Case 0 MsgBox "未知类型",vbExclamation Case 1 MsgB
Option Explicit
Private Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Sub Command1_Click()
Select Case GetDriveType("C:")
Case 0
MsgBox "未知类型",vbExclamation
Case 1
MsgBox "未知类型",vbCritical
Case 2
MsgBox "可移动磁盘",vbInformation
Case 3
MsgBox "本机磁盘",vbInformation
Case 4
MsgBox "网络磁盘",vbInformation
Case 5
MsgBox "光驱",vbInformation
Case 6
MsgBox "内存虚拟磁盘",vbInformation
End Select
End Sub
检测有无移动磁盘插入
Option Explicit
Private Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Sub Command1_Click()
If Ydcp() = False Then MsgBox "没有检测到移动磁盘" Else MsgBox "检测到移动磁盘"
End Sub
Private Function Ydcp() As Boolean
Dim i As Integer
Ydcp = False
For i = 65 To 90
If GetDriveType(Chr(i) & ":") = 2 Then
Ydcp = True
Exit Function
End If
Next i
End Function
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读