473,394 Members | 2,002 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,394 software developers and data experts.

List Of COM Ports

How can i get a list of available COM Ports on a machine?
Thanks
Jul 21 '05 #1
2 2326
Hi Krunoslav,

Here is the piece of code that list the COM ports .

You will need to add a reference to System.Management.dll

Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_POTSModem")
moReturn = moSearch.Get

For Each mo In moReturn
Debug.WriteLine(mo("Name") & " is attached to " &
mo("AttachedTo"))
Next

Hope this helps you.

Thanks
Raghavendra

"Krunoslav Ostrouska" <kr*****************@tele-haase.at> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
How can i get a list of available COM Ports on a machine?
Thanks

Jul 21 '05 #2
Hi Raghavendra.
I have tryed it but my ManagementObjectCollection dosent contain anything
(Count=0) !
My C# code:

ManagementObjectCollection managementCol;
ManagementObjectSearcher searcher;
searcher=new ManagementObjectSearcher("Select * from Win32_POTSModem");
managementCol=searcher.Get();
int i=managementCol.Count; // =0 ?!!
foreach (ManagementObject mob in managementCol)
Debug.WriteLine(mob.GetPropertyValue("Name") + "is attached to"
+mob.GetPropertyValue("AttachedTo"));

WinXPProf, VS2003
Do you have any ideas?
Thanks
Kruno

"Raghavendra T V" <ra*****@hotmail.com> schrieb im Newsbeitrag
news:Oh**************@TK2MSFTNGP09.phx.gbl...
Hi Krunoslav,

Here is the piece of code that list the COM ports .

You will need to add a reference to System.Management.dll

Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_POTSModem")
moReturn = moSearch.Get

For Each mo In moReturn
Debug.WriteLine(mo("Name") & " is attached to " &
mo("AttachedTo"))
Next

Hope this helps you.

Thanks
Raghavendra

"Krunoslav Ostrouska" <kr*****************@tele-haase.at> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
How can i get a list of available COM Ports on a machine?
Thanks


Jul 21 '05 #3

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

Similar topics

2
by: Claire | last post by:
I'm using the following code in an attempt to obtain a list of available serial ports. I expected to retrieve the same values as listed in hardware manager in Control panel but I'm not. I'm being...
1
by: SRB | last post by:
Hi, I am trying to find the list of available ports in a system using C# with ..NET 1.1 Could you please lead me to any APi's or the algorithm to find the ports available. Any help with...
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: Krunoslav Ostrouska | last post by:
How can i get a list of available COM Ports on a machine? Thanks
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...
4
by: Joachim | last post by:
How can I find out what COM ports that exists on my computer?
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...
11
by: kudruu | last post by:
Hi, I am trying to find a way to populate a list of active Com ports on a computer. There may be around 30 on one computer and all connected to different Buses but I am looking for one in...
3
by: kudruu | last post by:
Hi, I tried posting this in comp.lang.C but need more specific help using winAPI. I am trying to find a way to populate a list of active Com ports on a computer. There may be around 30 on one...
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:
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: 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...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.