我这里有个连接【宽带连接】,怎样可以判断这个连接是否已经连接,哪位高手帮忙解决下(详细代码)
if(???)
{
    ...
}
else
{
    ...
}
帮帮忙,谢谢!!!

解决方案 »

  1.   

    private Socket TSocket
    if(TSocket !=null)
      

  2.   

            private void button1_Click(object sender, EventArgs e)
            {
                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.FileName = "cmd.exe";
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardInput = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = true;
                p.StartInfo.CreateNoWindow = true;
                string strOutput = null;            try
                {
                    p.Start();
                    p.StandardInput.WriteLine("rasdial");
                    p.StandardInput.WriteLine("exit");
                    strOutput = p.StandardOutput.ReadToEnd();
                    p.WaitForExit();            }
                catch (Exception ex)
                {
                    strOutput = ex.Message;
                    System.Threading.Thread.Sleep(1000);
                }
                finally
                {
                    if (p != null)
                        p.Close();
                }
                if (strOutput.IndexOf("已连接") >= 0)
                {
                    MessageBox.Show("已连接");
                }
                else
                {
                    MessageBox.Show("未连接");
                }
            }
      

  3.   

    可以参考:
    http://blog.csdn.net/huangyaoshifog/archive/2009/08/24/4474834.aspx