Exemplo n.º 1
0
        private void BTKillApp_Click(object sender, EventArgs e)
        {
            var list = CMDNetstatTool.FindByPort(int.Parse(TBPort.Text), false);

            if (ListTool.HasElements(list) && list.Count == 1)
            {
                try
                {
                    Process p = Process.GetProcessById(list.First().Item2);
                    p.Kill();
                }
                catch { }
            }
        }
Exemplo n.º 2
0
 private void BTFindPort_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(TBPort.Text))
     {
         var list = CMDNetstatTool.FindByPort(int.Parse(TBPort.Text));
         if (ListTool.HasElements(list))
         {
             list.ForEach(x =>
             {
                 string name = "-";
                 string file = "-";
                 try
                 {
                     Process p = Process.GetProcessById(x.Item2);
                     name      = p?.ProcessName;
                     file      = p?.MainModule.FileName;
                 }
                 catch { }
                 TBRs.AppendText($"{x.Item1}, {x.Item2}, {name}, {file}");
                 TBRs.AppendText(Environment.NewLine);
             });
         }
     }
 }