Senin, 20 Oktober 2014

Membuat deteksi driver menggunakan Visual Basic 2008


Deteksi driver





Public Class Form1
    Dim vada As String
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim s As String
        Dim i As Integer
        Dim indr As IO.DriveInfo



        For Each indr In IO.DriveInfo.GetDrives
            If indr.DriveType = _
                IO.DriveType.Removable And _
                                indr.IsReady Then
                s = indr.Name
            End If
        Next
        s = Replace(s, ":\", "")



        If vada <> s Then
            'pemasangan
            For i = 1 To Len(s)
                If InStr(vada, Mid(s, i, 1)) = 0 Then
                    Label1.Text = _
                    "Status = Drive " & Mid(s, i, 1) & ":\" & " (terpasang)"
                End If
            Next
            'pencabutan
            For i = 1 To Len(vada)
                If InStr(s, Mid(vada, i, 1)) = 0 Then
                    Label1.Text = _
                    "Status = Drive " & Mid(vada, i, 1) & ":\" & "(telah dicabut)"
                End If
            Next
            vada = s
        End If


    End Sub

   
   
End Class

Tidak ada komentar:

Posting Komentar