欢迎大家访问我的网站!

vb 获取U盘

思博2022-10-09 22:33:02553编程开发
Private Sub Command1_Click()
Set d = CreateObject("Scripting.FileSystemObject")
For i = 68 To 90
If d.DriveExists(Chr(i)) Then
If (d.GetDrive(Chr(i)).DriveType = 1) Then
Text1.Text = Chr(i)
Else
Text1.Text = "没有"
End If
End If
Next
End Sub

'判断U盘并且获取盘符

Private Function Ydcp() As Boolean
Set d = CreateObject("Scripting.FileSystemObject")
Ydcp = False
For i = 68 To 90
If d.DriveExists(Chr(i)) Then
If (d.GetDrive(Chr(i)).DriveType = 1) Then
Text1.Text = Chr(i) & ":\"
Ydcp = True
End If
End If
Next
End Function

Private Sub Timer1_Timer()
If Ydcp() = False Then Text1.Text = "没有检测到移动磁盘" Else Text1.Text = Text1.Text
End Sub


转载声明:本站发布文章及版权归原作者所有,转载本站文章请注明文章来源!

本文链接:http://lxkj.vip/?id=81

网友评论