Com port listing

  • Thread starter Thread starter EMW
  • Start date Start date
E

EMW

Hi,

I'm looking for a way to get a list of all the com ports on a pc.
It doesn't matter if they are free or not or if they are virtual of
physical.

Who can help me?
I've tried google, but nothing clear yet...

rg,
Eric
 
Hi,

You can use the wmi for that. The win32_portconnector class
contains the info you are looking for. Add a reference to
system.management.

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_PortConnector")

moReturn = moSearch.Get

For Each mo In moReturn
Dim strOut As String
strOut = mo("ExternalReferenceDesignator").ToString
If strOut.Length < 1 Then
strOut = mo("InternalReferenceDesignator").ToString
End If
Debug.WriteLine(strOut)
Next

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_portconnector.asp

Ken
----------------------
Hi,

I'm looking for a way to get a list of all the com ports on a pc.
It doesn't matter if they are free or not or if they are virtual of
physical.

Who can help me?
I've tried google, but nothing clear yet...

rg,
Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top