473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Detecting USB Ports

I'm looking for a way to detect available USB ports on a machine using VB
..NET. It would also be advantegous if I could tell if they had hardware
plugged into them as well.

Any help is appreciated,

Thanks,
Deab

Jul 22 '05 #1
2 2607
Dean,

I have not done it for USB, but I have done it for COM ports and it works
well. You might be able to do something similar. Here is the code for COM
ports ( it is C# but should be easy to port to VB.NET):

RegistryKey comPortKey = Registry.LocalMachine.OpenSubKey(
"HARDWARE\\DEVICEMAP\\SERIALCOMM" );

string[] portNames = comPortKey.GetValueNames();

for( int x=0; x<portNames.Length; x++ )
{
string comPortValue = ( string )comPortKey.GetValue( portNames[ x ] );
comPorts.Add( comPortValue, comPortValue );
}

Hope that helps somewhat

-Robb
Jul 22 '05 #2
in vb.net:
Dim comPortKey As RegisTryKey =
RegisTry.LocalMachine.OpenSubKey("HARDWARE\\DEVICE MAP\\SERIALCOMM")

Dim portNames() As String = comPortKey.GetValueNames()

Dim x As Integer
For x = 0 To portNames.Length- 1 Step x + 1
Dim comPortValue As String = CType(comPortKey.GetValue(portNames( x
)), String)
comPorts.Add(comPortValue, comPortValue)
Next

regards,

Robb Gilmore wrote:
Dean,

I have not done it for USB, but I have done it for COM ports and it works
well. You might be able to do something similar. Here is the code for COM
ports ( it is C# but should be easy to port to VB.NET):

RegistryKey comPortKey = Registry.LocalMachine.OpenSubKey(
"HARDWARE\\DEVICEMAP\\SERIALCOMM" );

string[] portNames = comPortKey.GetValueNames();

for( int x=0; x<portNames.Length; x++ )
{
string comPortValue = ( string )comPortKey.GetValue( portNames[ x ] );
comPorts.Add( comPortValue, comPortValue );
}

Hope that helps somewhat

-Robb

Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jive | last post by:
The short form of the question is, how can I trace memory usage (preferably from C) with an eye toward finding out if I'm leaking memory? I would have thought there would be a ton of info on...
0
by: pothik05 | last post by:
Hi, We are using an application (the application uses WMI componenets) to change the IIS metabase of Server A from Server B. There is a firewall between Server A and Server B. Couple of weeks...
2
by: Hemant Shah | last post by:
Folks, How many tcp ports does DB2 server use? I installed UDB 8.2 on a AIX system and created several instances. I used consecutive ports for each instance, but when I look at /etc/services...
3
by: andyI | last post by:
Where do I find information on how to address and pass data to and from the serial ports and USB ports in VB. VB6 supports the serial ports easily but I see no reference to using the USB ports....
2
by: Dean | last post by:
I'm looking for a way to detect available USB ports on a machine using VB ..NET. It would also be advantegous if I could tell if they had hardware plugged into them as well. Any help is...
1
by: henrycortezwu | last post by:
Hi All, I'm trying to connect to a virtual port (COM19, OUTGOING, "Bluetooth Serial Port") using VS2005 System.IO.Ports. When I ran the ff code below here's what happens. 1) VS2005 Compiles w/o...
2
by: joaquimfpinto | last post by:
Dear All, I made an app in c# that uses several serial ports. For the serial ports I use a pnp Sunix board, some with 8 serial ports other with 4 or even 2 serial ports. Whenever I use the...
3
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello everyone, I am using .net remoting. Is there any way to find out the list of open ports. Thanks.
10
by: sklett | last post by:
I'm trying to send some printer commands (ZPLII) to an attached USB printer using the SerialPort component. I didn't get very far at all. In fact I haven't gotten anywhere. The first problem I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.