Dear,
How can we detect usb is plugged using visual basic 6. I want to send a simple note to my application as soon as usb is plugged in machine using vb6.
Hope i will get best answer from you.
Thank you and regards
Visual Basic ClassicChat / IM
Last Comment
at_the_biginning
8/22/2022 - Mon
Showkatdar
ASKER
Is there any way in vb6 to detect usb as it is plugged in
Then add a ListBox to the project
Now add this code to the project:
Private Sub Form_Load()
Call Check
End Sub
Private Sub SysInfo1_DeviceArrival(ByVal DeviceType As Long, ByVal DeviceID As Long, ByVal DeviceName As String, ByVal DeviceData As Long)
Call Check
End Sub
Private Sub SysInfo1_DeviceRemoveComplete(ByVal DeviceType As Long, ByVal DeviceID As Long, ByVal DeviceName As String, ByVal DeviceData As Long)
Call Check
End Sub
Sub Check()
Dim FSO As New Scripting.FileSystemObject, drv As Scripting.Drive
List1.Clear
For Each drv In FSO.Drives
If drv.IsReady Then
If drv.DriveType = Removable Then
List1.AddItem drv.DriveLetter & ":"
End If
End If
Next
End Sub