Home > Software engineering >  Please expert help, really appreciate
Please expert help, really appreciate

Time:10-01

Dim TcpRow As MIB_TCPROW
Dim buff () As Byte
Dim cbRequired As Long
Dim nStructSize As Long
Dim nRows As Long
Dim CNT As Long
Dim TMP As String
Dim itmx As ListItem
Call GetTcpTable (ByVal 0 & amp; , cbRequired, 1) * (excuse me expert, the first argument should be a table type structure, why is Byal 0 & amp;)
If cbRequired & gt; 0 Then
ReDim buff As Byte (0 To cbRequired - 1)
If GetTcpTable (buff (0), cbRequired, 1)=ERROR_SUCCESS Then
'with the following CopyMemory Lenb to save the data of call
NStructSize=LenB (TcpRow)
'the first 4 bytes is a long plastic, pointed out the table entry
CopyMemory nRows, buff (0), 4
For CNT=1 To nRows
'move to the front after the four bytes of data extract,
'and transform it into TcpRow type
CopyMemory TcpRow, buff (4 + (CNT - 1) * nStructSize), nStructSize * (and it didn't see risk)
'the results fill in the list to see
With TcpRow
The Set itmx=LvwTcpTable. ListItems. Add (,, GetInetStrFromPtr (. DwLocalAddr))
Itmx. SubItems (1)=ntohs (. DwLocalPort)
Itmx. SubItems (2)=GetInetStrFromPtr (. DwRemoteAddr)
Itmx. SubItems (3)=ntohs (. DwRemotePort)
Itmx. SubItems (4)=(. DwState)
A member of the 'for MIB_TCP_STATE_DELETE_TCB,
The definition of 'MSDN only some illustrative
The Select Case. The dwState
Case MIB_TCP_STATE_CLOSED: TMP="close"
Case MIB_TCP_STATE_LISTEN: TMP="listening"
Case MIB_TCP_STATE_SYN_SENT: TMP="send"
Case MIB_TCP_STATE_SYN_RCVD: TMP="accept"
Case MIB_TCP_STATE_ESTAB: TMP="connect"
Case MIB_TCP_STATE_FIN_WAIT1: TMP="wait for fin 1
"Case MIB_TCP_STATE_FIN_WAIT2: TMP="wait for fin 2"
Case MIB_TCP_STATE_CLOSE_WAIT: TMP="closed until"
Case MIB_TCP_STATE_CLOSING: TMP="is closing"
Case MIB_TCP_STATE_LAST_ACK: TMP="ack" recent
Case MIB_TCP_STATE_TIME_WAIT: TMP="timed wait"
Case MIB_TCP_STATE_DELETE_TCB: TMP="TCB removed"
End the Select
Itmx. SubItems (5)=TMP
TMP=""
End With
Next
End the If
End the If
End Sub

CodePudding user response:

CbRequired GetTcpTable (buff (0), 1)=ERROR_SUCCESS first argument why use buff (0)
  • Related