Listview VB.NET的网络信息

时间:2014-12-03 02:28:14

标签: vb.net listview

大家好我正在尝试获取有关listview的活动连接的信息。

到目前为止,我有:

Dim allProcess As String
Dim sl As String = "ProcessSplit"
Dim ipProps As System.Net.NetworkInformation.IPGlobalProperties = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties()
For Each connection As System.Net.NetworkInformation.TcpConnectionInformation In ipProps.GetActiveTcpConnections
  Dim LEP As String = connection.LocalEndPoint.ToString
  Dim REP As String = connection.RemoteEndPoint.ToString
  Dim CState As String = connection.State.ToString
Next

如何为每个连接获取新的行条目?对不起,我刚开始。提前谢谢。

1 个答案:

答案 0 :(得分:0)

在For Each循环中,只需添加ListView添加代码:

Dim data(3) as String
Dim itm as ListViewItem
For Each connection As System.Net.NetworkInformation.TcpConnectionInformation In ipProps.GetActiveTcpConnections
  Dim LEP As String = connection.LocalEndPoint.ToString
  Dim REP As String = connection.RemoteEndPoint.ToString
  Dim CState As String = connection.State.ToString
  data(0) = LEP
  data(1) = REP
  data(2) = CState
Next

itm = New ListViewItem(data)
ListView1.Items.Add(itm)