应该是象这样吧:
AnsiString C = "netsh interface ip set address name = \"本地连接\" source = static addr = 192.168.0.1 mask = 255.255.255.0 gateway = 192.168.0.1 gwmetric = 1 ";
WinExec(C.c_str(),SW_HIDE);
如要更改DNS或WINS地址可将字符串C变为:
netsh interface ip set dns name = \"本地连接\" source = static addr = 192.168.0.1
或:
netsh interface ip set wins name = \"本地连接\" source = static addr = 192.168.0.1
也可以先生成一个文本文件Tem.txt内容如下:
pushd interface ip
set address name = "本地连接" source = static addr = 192.168.0.1 mask = 255.255.255.0
set address name = "本地连接" gateway = 192.168.0.1 gwmetric = 1
set dns name = "本地连接" source = static addr = 192.168.0.1
set wins name = "本地连接" source = static addr = 192.168.0.1
popd
然后在程序里执行:
AnsiString C = "netsh -f Tmp.txt";
WinExec(C.c_str(),SW_HIDE);
如果Temp.txt不在当前目录得修改命令行加上路径!