procedure SetDNSAddresses( sIPs : string );
begin
// 如果是 Windows NT用下面的代码
SaveStringToRegistry_LOCAL_MACHINE(
SYSTEM\CurrentControlSet +
\Services\Tcpip\Parameters,
NameServer,
sIPs );
// 如果你用的是Windows 95用下面的代码
SaveStringToRegistry_LOCAL_MACHINE(
SYSTEM\CurrentControlSet +
\Services\VxD\MSTCP,
NameServer,
sIPs );
end;
其中 SaveStringToRegistry_LOCAL_MACHINE 定义:
uses Registry;
procedure SaveStringToRegistry_LOCAL_MACHINE(
sKey, sItem, sVal : string );
var
reg : TRegIniFile;
begin
reg := TRegIniFile.Create( );
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.WriteString( sKey, sItem, sVal + #0 );
reg.Free;
end;