如何与USB设备通信?

如何与USB设备通信?

问题描述:



我正在一个需要vb检测2个USB设备并与之通信的项目.我是VB的新手.我想知道vb如何检测设备连接到哪个USB端口.如果可以,请向我发送源代码.我的电子邮件是*已删除邮件*.

顺便说一句,我已经从http://www.microsoft.com/downloads/e...DisplayLang=en下载并查看了代码.我了解此代码用于串行com RS232.它可以用于USB吗?

Hi,

I am working on a project which need vb to detect and communicate with 2 usb devices. I am quite new to VB. I would like to know how vb detect which usb port the device is connected to. Send me the source code if you can. My email is *REMOVED MAIL*.

Btw, I had downloaded and look at the code from http://www.microsoft.com/downloads/e...DisplayLang=en. I understand this code is used for serial com RS232. Will it work for USB?

Thanks.

在VB.Net中访问USB驱动器没有什么例外.
您可以使用DriveInfo(Syste.IO命名空间)类来访问可移动设备,例如USB.
有一个IsReady属性,它可以告诉您是否已连接USB设备.

在驱动器信息上找到一些很好的示例(它们全部在C#中)
1. http://www.majstro.com/Web/Bedrijf/cs/cs_System_IO_DriveInfo.html [^ ]
2. http://msdn.microsoft.com/en-us/library/system. io.driveinfo.aspx [ ^ ]
There is nothing exceptional in accessing USB drive in VB.Net.
You can make use of DriveInfo (Syste.IO namespace) class to access the removable device like USB.
There is a property IsReady which tells whether USB device is connected or not.

Find some good examples on drive info (they are all in C#)
1. http://www.majstro.com/Web/Bedrijf/cs/cs_System_IO_DriveInfo.html[^]
2. http://msdn.microsoft.com/en-us/library/system.io.driveinfo.aspx[^]