[英]How to modify dns server in C++?
I want to change the primary dns server to some ip(eg 8.8.8.8), for all active adapters. 我想将所有活动适配器的主DNS服务器更改为某些IP(例如8.8.8.8)。
I tried to modify the registry, for all interfaces under HKEY_LOCAL_MACHINE\\\\SYSTEM\\\\CurrentControlSet\\\\Services\\\\Tcpip\\\\Parameters
, the NameServer
is changed to what i want. 我试图修改注册表,对于HKEY_LOCAL_MACHINE\\\\SYSTEM\\\\CurrentControlSet\\\\Services\\\\Tcpip\\\\Parameters
下的所有接口, NameServer
都更改为我想要的名称。
However it doesn't work. 但是,它不起作用。 ipconfig /all
shows that the dns is changed, however the system seems didn't apply that. ipconfig /all
显示dns已更改,但是系统似乎未应用该更改。 If I open the attribute of TCP/IPv4
, the dns is already changed, then i click OK
, until now the dns is put into use. 如果打开TCP/IPv4
的属性,则dns已更改,然后单击OK
,直到现在使用dns。
Could someone tell me how to solve this? 有人可以告诉我如何解决吗? you may go some other ways, besides registry. 除了注册表外,您还可以采用其他方法。
Update: what i did will finally apply, after about 6~8 mins. 更新:大约6〜8分钟后,我所做的最终将适用。
只是为了有人需要,最后我使用ipconfig /registerdns
刷新注册表中的dns配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.