473,409 Members | 2,034 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,409 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 1447
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: -------------...
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
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.