Hi NickHK,
There's no question that the code is doing what was requested. Nonetheless,
you seem to have taken exception to my post and made it a pet peeve. I
apologize if that's not the case. I would like to explain myself though!
The first part of my reply was to Chip's post, as a courtesy confirmation to
Chip, with respect to his statement of:
"I don't have a USB drive to test this, so take it as a shot in the dark."
It's quite clear here that he knows it's required for the code to work! So
the second part of my reply was intended for the OP, who may not know it's
required, based on his statement of:
"Is the any code to determine which drive is allocated to the USB device ?"
which suggests he's looking to query the USBs for a drive. Now WE obviously
understand what he means, but does he? Fact is, he's querying DRIVES, not USB
devices.
Not all USB devices need to be "plugged in" to be enumerated after they've
been installed. Fact is, you can plug the same device, say a printer for
example, into another USB port and Windows will take you down the "Found New
Hardware" journey again, even though the printer was previously installed on
that machine. Now there's 2 printers listed, one for each USB's address. If
you query printers on that system, you'd get both of them listed. If you
query the USB ports on that system, and what devices are assigned them,
you'll get both printers listed.
I didn't feel the OP needed this much info, but I did feel (at the time)
that it might be necessary to point out that the drive must be plugged in. So
what might be "obvious" to some, may not be that to others.
Again, I apologize if I've misread the tone of your persistence with this. I
don't mean to be contentious!
Regards,
Garry