473,395 Members | 1,532 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,395 software developers and data experts.

Comm Ports

Hi All and seasons greetings.

Is there an easy way of getting a list of current Comm ports on a machine?
I suspect that most machines these days have 1 and 2, but there could be
others and I would like to get a list of them to offer the end user.

Many thanks,
Steve.

Dec 26 '05 #1
3 1519
Hi,

You can use WMI, which will report which serial ports are installed (but,
the System.Management wrapper doesn't seem to work for anything other than
installed modems -- I have example code in my book). Or, you can simply
open each possible port in turn. If the port opens it is available, and
(usually) if there is an error, the error return will allow you to determine
if some other program is using the port.

The System.IO.Ports.GetPortNames method in Visual Studio 2005 has this
"built-in."

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
www.mabry.com/vbpgser4 to order.
Dec 27 '05 #2
Here's the code (*borrowed* from Microsoft):

Private Sub DisplaySerialPortNames()
Dim sp As System.Collections.ObjectModel.ReadOnlyCollection( Of
String)

For Each sp As String In My.Computer.Ports.SerialPortNames
System.Console.WriteLine(sp)
Next
End Sub
For further info, check out Microsoft's site:

http://msdn2.microsoft.com/library/9wahf8t8.aspx
"Steve" <st***************@ntlworld.com> wrote in message
news:%U*******************@newsfe4-win.ntli.net...
Hi All and seasons greetings.

Is there an easy way of getting a list of current Comm ports on a machine?
I suspect that most machines these days have 1 and 2, but there could be
others and I would like to get a list of them to offer the end user.

Many thanks,
Steve.

Jan 16 '06 #3
This is probably beside the point, but I really have needed to vent about
this for about three months... the new Dell systems are not shipping with
COM or keyboard ports any more, unless if you explicitely request the
adapter for an extra $15.00. Apparently the world no longer has need for
COM ports.

Jay Taplin, MCP

"Steve" <st***************@ntlworld.com> wrote in message
news:%U*******************@newsfe4-win.ntli.net...
Hi All and seasons greetings.

Is there an easy way of getting a list of current Comm ports on a machine?
I suspect that most machines these days have 1 and 2, but there could be
others and I would like to get a list of them to offer the end user.

Many thanks,
Steve.

Jan 16 '06 #4

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

Similar topics

0
by: Greg Pedder | last post by:
Hello. I have an application that uses the Java Communications API to use a modem. At startup, the application checks to see what serial devices are connected. For each serial device, the app...
1
by: Ky Nguyen | last post by:
Hi all, I would like to obtain a piece of codes (a full version or just an example) dealing with asynchronous communication via COM: serial port. I dont mind whether it is window-based or...
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....
1
by: James L | last post by:
Is there any code to get the number of comm ports detected by the pc? Cheers.
7
by: Padu | last post by:
Hi Everybody, I'm a newcomer from the Delphi world and I'm going to start developing my new project (a robot control app) in C#. One of the requirements is to communicate using RS232 (well,...
0
by: joaquimfpinto | last post by:
Hi All, I've an application that write and read from different serial ports. I made a class with an object from Charon Communications. On the main form I create several instances of that...
2
by: Hank | last post by:
Hello, I would like to get some opinions on using the Comm Port with Access 2000. We have a few jobs coming in that require us to interface with a PLC via the Comm Port. My partner feels we...
0
by: alvatar | last post by:
I am doing a project on microcontrollers and want to be able to send and receive data via RS232 serial cable. Right now, my PIC microcontroller code is able to send string data to the computer and...
9
by: rajujrk | last post by:
hi, currently i am doing the project to send the sms from PC to Mobile and vice versa using GSM modem. I successfully done this process in Hyperterminal. First i connect the GSM modem in COM1 port...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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...

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.