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

Finding number of Com ports on a machine

Hi,

I've worked out how to find the 2 COM Ports on my motherboard ok, using
System.Management namespace and looking for Win32_SerialPort.

Problem now, is I have 3 COM Ports on USB connections, but can't seem to
find a way to query for them.

Any suggestions?

rollasoc
Jul 21 '05 #1
2 1446
I do it by iterating through each possible COM port attempting to open each
one in turn. Something like this:

FOR nPort = 1 to MaxPorts
Attempt to open COM<nPort>
IF (it succeeded)
Add nPort to list of available ports
Close COM<nPort>
ENDIF
ENDFOR
"rollasoc" <ho*****@hotmail.com> wrote in message
news:uV**************@TK2MSFTNGP10.phx.gbl...
Hi,

I've worked out how to find the 2 COM Ports on my motherboard ok, using
System.Management namespace and looking for Win32_SerialPort.

Problem now, is I have 3 COM Ports on USB connections, but can't seem to
find a way to query for them.

Any suggestions?

rollasoc

Jul 21 '05 #2
Ok there was a great article that touched on this sort of thing, I will also
state that I didn't try this but believe the article is relevant to your
problem/issue/question.

http://msdn.microsoft.com/library/de...us/dncodefun/h
tml/code4fun12102003.asp

Coding in the Blue Glow
Duncan Mackenzie
Microsoft Developer Network
December 11, 2003

He writes a number of nice articles on well stuff he feels like I guess.

Hope it helps.

-Evan

"rollasoc" <ho*****@hotmail.com> wrote in message
news:uV**************@TK2MSFTNGP10.phx.gbl...
Hi,

I've worked out how to find the 2 COM Ports on my motherboard ok, using
System.Management namespace and looking for Win32_SerialPort.

Problem now, is I have 3 COM Ports on USB connections, but can't seem to
find a way to query for them.

Any suggestions?

rollasoc

Jul 21 '05 #3

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

Similar topics

8
by: ben | last post by:
hello, i'm trying to answer a "prove an upper bound on the number of machine instructions required to process M connections on N objects" exercise from an algorithms book. i don't understand a...
3
by: rollasoc | last post by:
Hi, Anyone know a way of working out the total number and which COM ports exist on a machine, using C#? rollasoc
0
by: rollasoc | last post by:
Hi, Ok, sussed how to find the 2 COM Ports on my motherboard ok, using System.Management namespace and looking for Win32_SerialPort. Problem now, is I have 3 COM Ports on USB connections, but...
2
by: rollasoc | last post by:
Hi, I've worked out how to find the 2 COM Ports on my motherboard ok, using System.Management namespace and looking for Win32_SerialPort. Problem now, is I have 3 COM Ports on USB connections,...
11
by: John | last post by:
Is there a way to find the number of processors on a machine (on linux/ windows/macos/cygwin) using python code (using the same code/cross platform code)?
25
by: Daniel Kraft | last post by:
Hi, I do need to implement something similar to C++'s std::bitset in C; for this, I use an array of int's to get together any desired number of bits, possibly larger than 32/64 or anything like...
2
by: justinanthonyhamilton | last post by:
Hello, everyone. I recently took a class on Data Structures in C++ (using D.S. Malik's C++ Programming: Program Design Including Data Structures), and while I learned a good about specific data...
3
by: Akash | last post by:
Hi, I am using getProcessTimes API for calculating CPU Usage On a Multi-Core processor i have observed that the %CPU Usage that is multiple of the number of cores of the processor Is there any...
1
by: bharathreddy | last post by:
This article will explain how we can get the count of weekdays in between two dates. This will be usefull if we want to count the number of working days between two dates. Example: -------------...
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
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
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.