private void Click_CloseAllRemote(object sender, EventArgs e) { if (War.HWnd != IntPtr.Zero) { string[] TCPlist = Disconnecter.Connections(); //TCP连接的位置 if (RB_CloseDescConnection.Checked) { int[] remoteProt = Disconnecter.GetRemoteProt(); string orderRemote = TX_ClosOrderRemote.Text; if (orderRemote.Length > remoteProt.Length) { orderRemote = orderRemote.Substring(0, remoteProt.Length); } if (remoteProt.Length != 0) { for (int i = 0; i < TX_ClosOrderRemote.Text.Length; i++) { Disconnecter.CloseRemotePort(remoteProt[(int)orderRemote[i]]); } } } else { //MessageBox.Show("请选择踢出方式", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
/// <summary>根据数组索引断开端口 /// /// </summary> /// <param name="index"></param> public void ClosRemoteByIndex(int index) { if (Disconnecter.GetRemoteProt().Length >= index) { int[] RemoteProt = Disconnecter.GetRemoteProt(); Array.Sort(RemoteProt); for (int i = 1; i < RemoteProt.Length; i++) { Console.WriteLine(RemoteProt[i]); } try { Disconnecter.CloseRemotePort(RemoteProt[index]); } catch (Exception ex) { ex.Message.ToString(); } } }