防火牆的控制。
功能
- -添加防火牆例外端口
- -將應用程序添加到防火牆例外
- -刪除防火牆例外端口
- -刪除防火牆例外中應用程序
『紙上得來終覺淺,絕知此事要躬行』 數字是不會騙人的!四杯25度C的水加在一起就變開水了!
private void button1_Click(object sender, EventArgs e)
{
Ping p1 = new Ping();
p1.PingCompleted += new PingCompletedEventHandler(this.PingCompletedCallBack);
if (textBox1.Text.Trim().Length == 0)
{
return;
}
p1.SendAsync(textBox1.Text.Trim(), null);
}
private void PingCompletedCallBack(object sender, PingCompletedEventArgs e)
{
listBox1.Items.Clear();
if (e.Cancelled)
{
listBox1.Items.Add("Ping Canncel");
return;
}
if (e.Error != null)
{
listBox1.Items.Add("e.Error.Message");
return;
}
PingReply reply = e.Reply;
listBox1.Items.Add(reply.Address + " " + reply.Status.ToString());
if (reply.Status == IPStatus.Success)
{
listBox1.Items.Add("RoundTrip time:" + reply.RoundtripTime);
listBox1.Items.Add("Time to live:"+reply.Options.Ttl);
listBox1.Items.Add("Don't fragment:"+reply.Options.DontFragment);
listBox1.Items.Add("Buffer size:"+reply.Buffer.Length);
}
}