帮忙看一下:
Private Sub GetTcpDatas()
Dim tcpt As MIB_TCPTABLE
Dim TcpRow
As MIB_TCPROW
Dim Buffer()
As Byte
Dim LngRequired
As Long
Dim LngStructureSize
As Long
Dim LngRows
As Long
Dim LngCounter
As Long
Dim strTemps
As String
Dim ListX
As ListItem
LvwTcpTable.ListItems.Clear
GetTcpTable tcpt, LngRequired, 1
If LngRequired > 0 Then
ReDim Buffer(0 To LngRequired - 1) As Byte
If GetTcpTable(
Buffer(0), LngRequired, 1) = ERROR_SUCCESS Then
LngStructureSize = LenB(TcpRow)
'起始的四个字节,是做为表示进入点的数字
CopyMemory LngRows, Buffer(0), 4
For LngCounter = 1 To LngRows
'
将上述获得四个字节的相关数据,拷贝到
TcpRow
的结构之中
CopyMemory TcpRow, Buffer(4 + (LngCounter - 1) * LngStructureSize), LngStructureSize
'
将结果传送到
ListView
之中
With TcpRow
Set ListX = ListView1.ListItems.Add(, , GetInetAddrStr(.dwLocalAddr))
ListX.SubItems(1) = ntohs(.dwLocalPort)
ListX.SubItems(2) = GetInetAddrStr(.dwRemoteAddr)
ListX.SubItems(3) = ntohs(.dwRemotePort)
ListX.SubItems(4) = (.dwState)
Select Case .dwState
Case MIB_TCP_STATE_CLOSE_WAIT:
strTemps = "结束等待"
Case MIB_TCP_STATE_CLOSED:
strTemps = "已结束"
Case MIB_TCP_STATE_CLOSING:
strTemps = "结束中..."
Case MIB_TCP_STATE_DELETE_TCB:
strTemps = "已删除TCB"
Case MIB_TCP_STATE_ESTAB:
strTemps = "已连接"
Case MIB_TCP_STATE_FIN_WAIT1:
strTemps = "FIN延时处理1"
Case MIB_TCP_STATE_FIN_WAIT2:
strTemps = "FIN延时处理2"
Case MIB_TCP_STATE_LAST_ACK:
strTemps = "上次取得的确认信号"
Case MIB_TCP_STATE_LISTEN:
strTemps = "监听中..."
Case MIB_TCP_STATE_SYN_SENT:
strTemps = "传送"
Case MIB_TCP_STATE_SYN_RCVD:
strTemps = "数据接收中"
Case MIB_TCP_STATE_TIME_WAIT:
strTemps = "等候中..."
End Select
ListX.SubItems(4) = ListX.SubItems(4) & "(" & strTemps & ")"
strTemps = ""
End With
Next
End If
End If
End Sub
---------------------------
Microsoft Visual Basic
---------------------------
编译错误:
ByRef 参数类型不符
---------------------------
确定
帮助
---------------------------