好像太简单了,调用外部命令很容易做到,我找到了些例子,可能有重复
例子如下:
netsh interface ip address 本地连接 static 172.23.1.217 255.255.255.0 172.23.1.10
netsh interface ip set address 本地连接 static 192.168.0.199 255.255.255.0
cmd.exe /c netsh interface ip set address "本地连接" static 172.16.100.100 255.255.0.0 172.16.200.2 1
2000的DNS可以用
netsh interface ip set dns "本地连接" static 192.9.201.1
98系统有没有好办法???(修改注册表除外)?????
用命令吧:netsh interface ip set address 本地连接 static 192.168.0.199 255.255.255.0
2000
winexec(pchar('netsh interface ip set address "本地连接" static 172.16.100.100 255.255.0.0 172.16.200.2 1'),sw_hide);
98
修改注册表
如://注意得重启计算机才能真正生效
var
MyReg: TRegistry;
i : integer;
begin
MyReg := TRegistry.Create;
try
MyReg.RootKey := HKEY_LOCAL_MACHINE;
if MyReg.OpenKey('/Enum/Network/MSTCP',false) then
begin
for i := 1 to 9 do
begin
if MyReg.OpenKey('/Enum/Network/MSTCP/000' + inttostr(i),false) then
begin
MyReg.WriteString('IPAddress','192.9.201.9');
MyReg.WriteString('IPMask','255.255.255.0');
MyReg.WriteString('DefaultGateway','192.9.201.1');
MyReg.CloseKey;
Break;
end;
end;
end;
finally
MyReg.Free;
end;
end;
1.使用 netsh -c interface dump > config.txt
2.然后将生成的 config.txt 复制多份,并修改其内容使之符合你的要求
3.netsh -f config.txt
4.ok
2000 //ip 子网掩吗 网关
winexec(pchar('netsh interface ip set address "本地连接" static 172.16.100.100 255.255.0.0 172.16.200.2 1 '),sw_hide)
2000的DNS可以用
winexec(pchar('netsh interface ip set dns "本地连接" static 192.9.201.1'),sw_hide);