Brothers Inserito: 7 dicembre 2005 Segnala Inserito: 7 dicembre 2005 (modificato) Perchè se includo in un progetto più ampio una form con questo codicenon funziona mentre da solo funziona perfettamentePrecisamente mi diceLa dichiarazione della routine non corrisponde alla descrizione dell'evento o della routine con lo stesso nomee mi evidenzia questo codice:Private Sub ListView1_ColumnClick(ByVal ColumnHeader As ColumnHeaderChe corrisponde ad una funzione per riordinare le righeSe elimino questa funzione addizionaleesce un'altro errore:mi dice: Tipo non corrispondentee mi evidenzia questo codice:Set lstLine = ListView1.ListItems.Add(, , GetInetAddrStr(.dwLocalAddr))Non capisco come mai, se devo creare un modulo o no? o che altro.Grazie anticipateSotto metto tutto il codice:----------------------------------------------------------------Option ExplicitPrivate Type MIB_TCPROWdwState As LongdwLocalAddr As LongdwLocalPort As LongdwRemoteAddr As LongdwRemotePort As LongEnd TypePrivate Const ERROR_SUCCESS As Long = 0Private Const MIB_TCP_STATE_CLOSED As Long = 1Private Const MIB_TCP_STATE_LISTEN As Long = 2Private Const MIB_TCP_STATE_SYN_SENT As Long = 3Private Const MIB_TCP_STATE_SYN_RCVD As Long = 4Private Const MIB_TCP_STATE_ESTAB As Long = 5Private Const MIB_TCP_STATE_FIN_WAIT1 As Long = 6Private Const MIB_TCP_STATE_FIN_WAIT2 As Long = 7Private Const MIB_TCP_STATE_CLOSE_WAIT As Long = 8Private Const MIB_TCP_STATE_CLOSING As Long = 9Private Const MIB_TCP_STATE_LAST_ACK As Long = 10Private Const MIB_TCP_STATE_TIME_WAIT As Long = 11Private Const MIB_TCP_STATE_DELETE_TCB As Long = 12Private Declare Function GetTcpTable Lib "iphlpapi.dll" (ByRef pTcpTable As Any, ByRef pdwSize As Long, ByVal bOrder As Long) As LongPrivate Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dst As Any, src As Any, ByVal bcount As Long)Private Declare Function lstrcpyA Lib "kernel32" (ByVal RetVal As String, ByVal Ptr As Long) As LongPrivate Declare Function lstrlenA Lib "kernel32" (ByVal Ptr As Any) As LongPrivate Declare Function inet_ntoa Lib "wsock32.dll" (ByVal addr As Long) As LongPrivate Declare Function ntohs Lib "wsock32.dll" (ByVal addr As Long) As Long--------------------Public Function GetInetAddrStr(Address As Long) As StringGetInetAddrStr = GetString(inet_ntoa(Address))End Function---------------------Private Sub Form_Load()With ListView1.View = lvwReport.ColumnHeaders.Add , , "Local IP Address".ColumnHeaders.Add , , "Local Port".ColumnHeaders.Add , , "Remote IP Address".ColumnHeaders.Add , , "Remote Port".ColumnHeaders.Add , , "Status "End WithTimer1.Enabled = TrueEnd Sub----------------------------------Private Sub ListView1_ColumnClick(ByVal ColumnHeader As ColumnHeader)ListView1.SortKey = ColumnHeader.Index - 1ListView1.SortOrder = Abs(Not ListView1.SortOrder = 1)ListView1.Sorted = TrueEnd Sub-------------------------------------Public Function GetString(ByVal lpszA As Long) As StringGetString = String$(lstrlenA(ByVal lpszA), 0)Call lstrcpyA(ByVal GetString, ByVal lpszA)End Function-------------------------------------Private Sub Timer1_Timer()Dim TcpRow As MIB_TCPROWDim buff() As ByteDim lngRequired As LongDim lngStrucSize As LongDim lngRows As LongDim lngCnt As LongDim strTmp As StringDim lstLine As ListItemListView1.ListItems.ClearCall GetTcpTable(ByVal 0&, lngRequired, 1)If lngRequired > 0 ThenReDim buff(0 To lngRequired - 1) As ByteIf GetTcpTable(buff(0), lngRequired, 1) = ERROR_SUCCESS ThenlngStrucSize = LenB(TcpRow)'first 4 bytes indicate the number of entriesCopyMemory lngRows, buff(0), 4For lngCnt = 1 To lngRows'moves past the four bytes obtained above'to get data and cast into a TcpRow stuctureCopyMemory TcpRow, buff(4 + (lngCnt - 1) * lngStrucSize), lngStrucSize'sends results to the listviewWith TcpRowSet lstLine = ListView1.ListItems.Add(, , GetInetAddrStr(.dwLocalAddr))lstLine.SubItems(1) = ntohs(.dwLocalPort)lstLine.SubItems(2) = GetInetAddrStr(.dwRemoteAddr)lstLine.SubItems(3) = ntohs(.dwRemotePort)lstLine.SubItems(4) = (.dwState)Select Case .dwStateCase MIB_TCP_STATE_CLOSED: strTmp = "closed"Case MIB_TCP_STATE_LISTEN: strTmp = "listening"Case MIB_TCP_STATE_SYN_SENT: strTmp = "sent"Case MIB_TCP_STATE_SYN_RCVD: strTmp = "received"Case MIB_TCP_STATE_ESTAB: strTmp = "established"Case MIB_TCP_STATE_FIN_WAIT1: strTmp = "fin wait 1"Case MIB_TCP_STATE_FIN_WAIT2: strTmp = "fin wait 1"Case MIB_TCP_STATE_CLOSE_WAIT: strTmp = "close wait"Case MIB_TCP_STATE_CLOSING: strTmp = "closing"Case MIB_TCP_STATE_LAST_ACK: strTmp = "last ack"Case MIB_TCP_STATE_TIME_WAIT: strTmp = "time wait"Case MIB_TCP_STATE_DELETE_TCB: strTmp = "TCB deleted"End SelectlstLine.SubItems(4) = lstLine.SubItems(4) & "( " & strTmp & " )"strTmp = ""End WithNextEnd IfEnd IfEnd Sub-------------------------------------------------------- Modificato: 7 dicembre 2005 da Brothers
Messaggi consigliati
Crea un account o accedi per commentare
Devi essere un utente per poter lasciare un commento
Crea un account
Registrati per un nuovo account nella nostra comunità. è facile!
Registra un nuovo accountAccedi
Hai già un account? Accedi qui.
Accedi ora