In addition, it can be useful to get the port description(s). For this, you
would use System.Management. I provide examples in some detail for this in
my book (see below). Here is an excerpt.
Imports System.Management
Public ReadOnly Property PortDescriptions() As Array
Get
Dim PortDescriptionArray() As String = {}
Dim I As Integer
Dim pReturn As Management.ManagementObjectCollection
Dim pSearch As Management.ManagementObjectSearcher
Dim pObject As Management.ManagementObject
Dim sStatus As String = ""
pSearch = New Management.ManagementObjectSearcher("Select *from
Win32_PnPEntity")
pReturn = pSearch.Get
Try
For Each pObject In pReturn
If InStr(pObject("Name").ToString, "(COM") <> 0 Then
ReDim Preserve PortDescriptionArray(I)
PortDescriptionArray(I) = (pObject("Name").ToString)
I += 1
End If
Next
Catch ex As Exception
End Try
Return PortDescriptionArray
End Get
End Property
Dick
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See
www.hardandsoftware.net for details and contact information.