2011年5月15日 星期日

DriveInfo 類別運用USB裝置

參考來源
--
DriveInfo.DriverType 可以取得磁碟類型,包括 CDRom、Fixed、Network、NoRootDirectory、Ram、Removable 和 Unknown。
--
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 100
Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ListBox1.Items.Clear()
Dim di As DriveInfo
For Each di In DriveInfo.GetDrives
If di.DriveType = DriveType.Removable Then
ListBox1.Items.Add("偵測到" & di.Name & "抽取式存放裝置")
End If
Next
End Sub
End Class

沒有留言:

張貼留言