使用以下IP已知道,但如果修改为自动获取呢?
使用以下:
http://community.csdn.net/Expert/topic/4847/4847643.xml?temp=.1757013

解决方案 »

  1.   

    netsh interface ipset address name = "本地连接2" source = dhcp set dns name = "本地连接2" source = dhcp set wins name = "本地连接2" source = dhcp 
      

  2.   

    点击“自动获取”按钮,你new一个process,这个process调用cmd.exe,执行上面那些命令不就可以了?
      

  3.   

    shrinerain(圣影雨) ( ) 信誉:100  2006-08-08 10:31:00  得分: 0  
     
     
       点击“自动获取”按钮,你new一个process,这个process调用cmd.exe,执行上面那些命令不就可以了?
      
    ==========实在不知,能否给个代码,谢谢
      
     
      

  4.   

    private void button1_Click(object sender, System.EventArgs e)
    {
    string a= "set address  name =\"本地连接\" source = dhcp";
    string b="set dns name =\"本地连接\" source = dhcp";
    string c="set wins name =\"本地连接\" source = dhcp"; Process p = new 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;    
    p.Start (); p.StandardInput.WriteLine("netsh");
    p.StandardInput.WriteLine("interface");
    p.StandardInput.WriteLine("ip");
    p.StandardInput.WriteLine(a.ToString ());
    p.StandardInput.WriteLine(b.ToString ());
    p.StandardInput.WriteLine(c.ToString ());
    p.StandardInput.WriteLine("exit");
    p.StandardInput.WriteLine("exit");
    p.Close ();
    MessageBox.Show ("改变IP成功.");

    }