{
使用snmp协议,代码是剪接出来的
}
procedure CloseTcpConnect;
var
TcpRow : TMibTcpRow;
begin
try
TcpRow.dwLocalAddr := inet_addr(PChar(ListView1.Items[Index].SubItems.Strings[0])); // Local IP
TcpRow.dwLocalPort := (StrToInt(ListView1.Items[Index].SubItems.Strings[1])); // Local Port
TcpRow.dwRemoteAddr := inet_addr(PChar(ListView1.Items[Index].SubItems.Strings[2])); // Remote Ip
TcpRow.dwRemotePort := (StrToInt(ListView1.Items[Index].SubItems.Strings[3])); // Remote Port
TcpRow.dwState := MIB_TCP_STATE_DELETE_TCB; // 对指定的连接所做的动作,好像只能是删除,可以查一下MSDN
SetTcpEntry(TcpRow); //未加出错处理
MessageDlg('Succeed in close this connection!', mtInformation, [mbok], 0);
except
MessageDlg('Can''t close this connection.', mtWarning, [mbok], 0);
end;
end;