Com port listing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • EMW

    #1

    Com port listing

    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


  • Ken Tucker [MVP]

    #2
    Re: Com port listing

    Hi,

    You can use the wmi for that. The win32_portconne ctor class
    contains the info you are looking for. Add a reference to
    system.manageme nt.

    Dim moReturn As Management.Mana gementObjectCol lection

    Dim moSearch As Management.Mana gementObjectSea rcher

    Dim mo As Management.Mana gementObject

    moSearch = New Management.Mana gementObjectSea rcher("Select * from
    Win32_PortConne ctor")

    moReturn = moSearch.Get

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

    http://msdn.microsoft.com/library/de...tconnector.asp

    Ken
    ----------------------
    "EMW" <someone@MikroZ oft.com> wrote in message
    news:42c6e2be$0 $745$5fc3050@dr eader2.news.tis cali.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



    Comment

    • EMW

      #3
      Re: Com port listing

      Thanks!

      "Ken Tucker [MVP]" <vb2ae@bellsout h.net> schreef in bericht
      news:ecadHc2fFH A.1048@tk2msftn gp13.phx.gbl...[color=blue]
      > Hi,
      >
      > You can use the wmi for that. The win32_portconne ctor class
      > contains the info you are looking for. Add a reference to
      > system.manageme nt.
      >
      > Dim moReturn As Management.Mana gementObjectCol lection
      >
      > Dim moSearch As Management.Mana gementObjectSea rcher
      >
      > Dim mo As Management.Mana gementObject
      >
      > moSearch = New Management.Mana gementObjectSea rcher("Select * from
      > Win32_PortConne ctor")
      >
      > moReturn = moSearch.Get
      >
      > For Each mo In moReturn
      > Dim strOut As String
      > strOut = mo("ExternalRef erenceDesignato r").ToString
      > If strOut.Length < 1 Then
      > strOut = mo("InternalRef erenceDesignato r").ToString
      > End If
      > Debug.WriteLine (strOut)
      > Next
      >
      > http://msdn.microsoft.com/library/de...tconnector.asp
      >
      > Ken
      > ----------------------
      > "EMW" <someone@MikroZ oft.com> wrote in message
      > news:42c6e2be$0 $745$5fc3050@dr eader2.news.tis cali.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
      >
      >
      >[/color]


      Comment

      Working...