使用以下IP已知道,但如果修改为自动获取呢?
使用以下:
http://community.csdn.net/Expert/topic/4847/4847643.xml?temp=.1757013
使用以下:
http://community.csdn.net/Expert/topic/4847/4847643.xml?temp=.1757013
解决方案 »
- 如何自定义打印模板及使用该模板
- 高分请教,TextBox多行输入的数字的小数点精度问题~~~~~~~~~~~~
- 请问能不能.net有没有一个机制能够控制 动态引用的一个外部类(如dll)的操作权限?
- WinForm 中如何获得所有打开窗体的实例?
- 了解金碟和深圳现代(MCM)的朋友请帮忙指点......我该选择谁?
- DataGrid中使用超链接的问题
- 引用DLL问题,求高手解决.
- 请教:连接数据库问题
- 一个正则表达式的问题
- 请问从vb.net转到c#需要看什么书呢?
- socket客户端发送消息到socket服务器特别慢,但接收很快
- @@@@@@@@@@@@@捡分了;;;;;求最基础的正则表达式,要求输入全为整数,为什么我的^[0-9]$不行,
点击“自动获取”按钮,你new一个process,这个process调用cmd.exe,执行上面那些命令不就可以了?
==========实在不知,能否给个代码,谢谢
{
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成功.");
}