Home All Groups Group Topic Archive Search About
Author
2 Jul 2005 6:54 PM
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

Author
3 Jul 2005 12:34 AM
Ken Tucker [MVP]
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
----------------------
"EMW" <some***@MikroZoft.com> wrote in message
news:42c6e2be$0$745$5fc3050@dreader2.news.tiscali.nl...
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
Author
3 Jul 2005 7:48 AM
EMW
Thanks!

Show quoteHide quote
"Ken Tucker [MVP]" <vb***@bellsouth.net> schreef in bericht
news:ecadHc2fFHA.1048@tk2msftngp13.phx.gbl...
> 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
> ----------------------
> "EMW" <some***@MikroZoft.com> wrote in message
> news:42c6e2be$0$745$5fc3050@dreader2.news.tiscali.nl...
> 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
>
>
>