473,414 Members | 1,606 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,414 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 2611
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.