运行如下代码记得先要相用 Registry单元
function WriteRegistString(aRootkey: HkEY; const aRoot, aItem, aValue: String; canCreate: Boolean): Boolean;
begin
with TRegistry.Create do
try
Rootkey := aRootKey;
Result := OpenKey(aRoot,canCreate);
if Result then
WriteString(aItem,aValue);
finally
CloseKey;
Free;
end;
end;
//设置DNS的IP地址
procedure SetTCPIPDNSAddresses(aIP: String);
begin
WriteRegistString(HKEY_LOCAL_MACHINE,'SYSTEM/CurrentControlSet/Services/VxD/MSTCP'
,'NameServer',aIP,False);
end;
使用SetTCPIPDNSAddresses过程设置你的IP地址