2014-12-03 80 views
0

嗨,大家好,我想獲得關於活動連接到列表視圖的信息。網絡信息列表視圖VB.NET

到目前爲止,我有:

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 

我怎樣才能爲每個連接的新行條目?對不起,我剛剛開始。提前致謝。

回答

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)