How to get the data from a USB port in VB.NET

2019-01-15 01:04发布

问题:

I have developed a software for managing the details of patients, the software stores the data into MSsql database.... However, the data I need to get stored has to be read from an external device which transmits data... Now my query is how I can read that data using VB.NET 2010.

I have searched on net and found that I can use My.Computer.Port to read data from USB connected device, but I am unable to get its logic and any example to get this practically done...

I also been through many books to understand the practical way of doing this, but not yet resolved with anything.....

If somebody can help me with an example so that i get a way forward to accomplish my task....

回答1:

Here is what I found. You use the HID.dll to interface the usb ports. And you know the best part? I found some examples.

Here's a link that contains basic examples and tutorial for usb interfacing. The HID Page

Sample Project File



回答2:

You loop those : IO.DriveInfo.GetDrives() and check where DeviceType = IO.DriveType.Removable then the device name to use it copying data or other stuff

for details check this out : Detect USB drive



回答3:

Abhilash (I only asked this question)

I am adding this, Just to let you people know, my current understanding about the topic...

I actually asked for the question from one of my know person....

He explained me this:-

There are basically two ways to get data from an external instrument. The fist method is to use the software than came with the instrument. If the instrument has an interface of any type, there should be some software that reads the data. You can use this software to store the data to a file and your application will read a file with s fixed structure. very simple.

If the instrument provides a serial port but no software, then you can use the My.Computer.Port namespace to access the instrument's serial port. It's easy to send commands to a serial port and read back the response, but you have to know the commands that the other end recognizes. You will need detailed documentation about the device, which you will most likely find on the Internet.

The first approach is always preferrable. Of course, you have to associate the data with patients. This can be tricky. If you can find the software that allows you to download data from the instrument to your computer, it will be straightforward to acquire the data. Since someone must connect the device to a computer, they can also start the application and save the data to a file.