vb检查磁盘类型

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

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...