Saturday, June 19, 2010 5:40 PM
can any one tell me how to access a usb port in c# and vb.net. actually i am trying to send and receive a character from usb port.
please tell me the code for the above mentioned problem.
Saturday, June 19, 2010 6:33 PM
Usb is not a port like the serial port where you can send / recieve byes, its a bus that allows multiple devices to be on all talking in a different protocol, so there is no generic 'send/recieve byte' , communicating with usb devices is usually done though the vendor supplied driver and you'll have to contact the vendor to get additional programmin information. What device are you trying to communicate with?
Saturday, June 19, 2010 11:12 PM
what i get till now that you are using usb port and then u have some device like microcontroller or like that you want to communicate with them ?
or you are having flash drive and you want to write something on it ?
if the post helpful please mark it right else feel free to correct me
Wednesday, June 23, 2010 9:53 AMModerator
You can't access USB devices (or any other device) directly from user mode applications in windows, this is done by the Device driver. The software that came with the device includes a Device driver, a COM library and a VB sample. The VB sample uses the interface exposed by the COM library, if you want to build new (with extended functionality) applications using C#, you have to import the typelibrary to access the same COM object from managed code, However, if you meant that the functionality offered by the library is rather limitted, you will have to call Device driver API directly from C++ or C#(using Pinvoke), but it's obvious you will need the API's documentation.
A good start for USB in C# is this website.
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
- Marked As Answer by Helen ZhouModerator Friday, June 25, 2010 3:23 AM
Wednesday, November 03, 2010 10:32 PM
Is there an easy way to access usb devices? Because, I only want to access an usb flash drive and write on it.
Wednesday, November 03, 2010 11:23 PMFlash drives will just show up as any other drive and no special code is needed to access them.