PDA

View Full Version : Automatically detecting a USB device



Demon
- 3rd July 2006, 19:35
Hi,

I want an executable to start up whenever a specified USB device is connected. Is that done with a windows INF file? And if so, any idea on how to go about doing that?

Robert
:)

mister_e
- 3rd July 2006, 19:46
i would guess that you can load and hide a VB application using the Mecanique HID library, then somewhere in the HIDdetect event(or something like that), reading the according infos and launch your application if it match.

Demon
- 3rd July 2006, 19:51
zooooooooooooooooooo.........

That's the sound of all that information passing right over my head.

Robert
:D

mister_e
- 3rd July 2006, 19:58
begin slow, create a running application in VB with HID maker. Then scroll in the code onto the ...


'************************************************* ****************
' a HID device has been plugged in...
'************************************************* ****************
Public Sub OnPlugged(ByVal pHandle As Long)
Dim DeviceHandle As Long
If hidGetVendorID(pHandle) = VendorID And hidGetProductID(pHandle) = ProductID Then
' Here you have a perfect match of the pre-define USB device


' ** YOUR CODE HERE **
End If
End Sub


Do you still hae the VB PDFs i think i already sent you? If not let me know... soon 'cause i have to go in few minutes.

Demon
- 3rd July 2006, 20:05
Ah, yes, I saw that in the code that was generated when I was looking at it in VB.

I won't be able to test that until I get the proper cap and have the device recognized. I have a box full of VCR circuits and other crap and I can't find it.

I hope this doesn't mean I have to clean my basement...

Robert
:)

mister_e
- 3rd July 2006, 20:08
if you have some amplifier or else audio, look close to the input/output jack. Some use 0.47uF (470nf) ... TADA!

Now, i have to trash out serious car radio stuff. if you're interested.. it will be free. it takes too much room in here and i'll probably never use them as spare parts. I plan to close the repair shop in few months/days

Demon
- 25th July 2006, 23:21
i would guess that you can load and hide a VB application using the Mecanique HID library, then somewhere in the HIDdetect event(or something like that), reading the according infos and launch your application if it match.

What happens when you connect a USB mouse in Windows XP? How does it know to start a Logitech software? That's what I'm after.

Robert
:)

mister_e
- 26th July 2006, 00:55
From what i feel, all driver should run in background, when they detect the right USB device, they run the program

I know it doesn't help :)

Be back later...

Demon
- 26th July 2006, 01:12
Yeah, I know I could do that. I probably will have to, but I'm sure there's a more efficient way to do this.

When you plug a USB device, XP will ask you for a driver to associate with it if it doesn't have one already. I'd like to do this like the pros if I can.

Robert
:)

mister_e
- 26th July 2006, 02:41
sure but as far as i know, there's no commercial stuff who launch an application automatically like that... as i know so far. Usually when you first connect your device it will send you to the software and/or driver installation plahplah.. not much... oh well i can't know every USB device on the market so far so i can be wrong.

So you don't have any other choice to run something in background. I mean a little few Kbs application wich you add to the Windows Registry list (run, Runonce or else) wich just monitor the VendorId or whatever else, then once you got a match it launch the main application.

Maybe there's other much elegant way.. now i don't know :(