Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting USB device getting plugged in. 2

Status
Not open for further replies.

PockyBum522

Programmer
Jun 10, 2003
239
US
Here's what I want to do:

Detect the plugging in of my generic USB bluetooth dongle and automatically run my bluetooth manager (bluesoleil is the name of the program) when it is plugged in. Is there a way to do this?

So far the only way I've figured is I think hardware info is stored in the registry, and I need to research where and how I can use this, but I'd like a more direct method (Windows api) or something, if possible.
 
Add a SysInfo control to your form, and investigate the DeviceArrival event
 
Okay, I'm not sure how to use this. I've added the sysinfo control and I've tried both:

Private Sub SysInfo1_DeviceArrival()
Label1.Caption = "Moof"
End Sub

Which never does anything (Even if I plug in a device)

And a timer that changes label1.caption to whatever sysinfo1.devicearrival

Which gives me: "Method or data member not found"

Please help me, and thank you for your help so far.
 
Hmm, interesting, you are right: certainly works for USB keyfobs ... but it doesn't work for my iPAQ
 
Hmm, well thanks for your help. Let's see if I can detect a PCMCIA card with it. Why am I getting a "method or data member not found" When I run this:

Label1.Caption = SysInfo1.DeviceArrival
 
That's because SysInfo1.DeviceArrival is an event not a method. If I use the event:
Code:
Private Sub SysInfo1_DeviceArrival()
Msgbox = "New device"
End Sub
I get a message box for my memory stick, but not for my USB printer.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Which is what I was afraid of. Neither my bluetooth usb key is detected, or my PCMCIA card. That's annoying, although I managed to find a key in the registry I can read to see if the bluetooth key is plugged in, I can't figure out how to detect my WiFi card :(
 
I got it to detect my PCMCIA card with:

Private Sub SysInfo1_DeviceArrival(ByVal DeviceType As Long, ByVal DeviceID As Long, ByVal DeviceName As String, ByVal DeviceData As Long)
MsgBox "Arrival!"
End Sub
 
It detects my usb bluetooth device too, thanks. Now, two last things, how do I tell what device arrived, and how do I tell if a device is present at runtime?
 
Look in VBHelp (or MSDN) for "DeviceArrival Event Example"

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
I believe I should let your guys know that I've succeded, and I appreciate all you guys helping. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top