Home > Back-end >  Delphi 7 how to write a modify ip4 gateway such as DNS switch Windows 7 system
Delphi 7 how to write a modify ip4 gateway such as DNS switch Windows 7 system

Time:09-19

As shown in figure, doing an IP address switch program recently, because of my technology small white, please grant instruction expert,

CodePudding user response:

Study the CMD netsh command

CodePudding user response:

 if regRootKey. OpenKey (' \ SYSTEM \ CurrentControlSet \ Services \ Tcpip \ Parameters \ Interfaces \ '+ CardList. Strings [cbb1. ItemIndex], True) 
Then the begin
If CheckBox1. Checked//judge whether to enable the DHCP
Then the begin
RegRootKey. WriteInteger (' EnableDHCP ', 1);
RegRootKey. WriteString (' NameServer ', ');
WriteIp (regRootKey CurrentKey, 'IPAddress', '0.0.0.0');
WriteIp (regRootKey CurrentKey, 'SubNetMask', '0.0.0.0');
WriteIp (regRootKey CurrentKey, 'DefaultGateway', ');
End
The else begin
RegRootKey. WriteInteger (' EnableDHCP, 0).
RegRootKey. WriteString (NameServer, Trim (Combobox1. Text));
WriteIp (regRootKey CurrentKey, 'IPAddress, Trim (Edit2. Text));
WriteIp (regRootKey CurrentKey, 'DefaultGateway, Trim (Edit4. Text));
WriteIp (regRootKey CurrentKey, 'SubNetMask, Trim (Edit3. Text));
WriteIp (regRootKey CurrentKey, 'DefaultGateway, Trim (Edit4. Text));
end;
end;

Can be set by the registry, IP, the code is shown,
  • Related