procedure SetTCPIPDNSAddresses( sIPs : string );
begin
// WINDOWS NT
SaveStringToRegistry_LOCAL_MACHINE(
'SYSTEM/CurrentControlSet' +
'/Services/Tcpip/Parameters',
'NameServer',
sIPs );
//if using Windows 95
SaveStringToRegistry_LOCAL_MACHINE(
'SYSTEM/CurrentControlSet' +
'/Services/VxD/MSTCP',
'NameServer',
sIPs );
end;
2. 其中 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;