在网络适配器中添加DNS条目
C++ Add DNS entry into network adapter
我必须在windows的网络适配器设置中以编程方式添加DNS服务器地址。编程语言为c++。
你可以看看IP Helper API
你可以找到如何使用
使用iphelp设置DNS并在CodeProject上注册。
bool RegSetDNS(LPCTSTR lpszAdapterName, LPCTSTR pDNS)
{
HKEY hKey;
string strKeyName = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\";
strKeyName += lpszAdapterName;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
strKeyName.c_str(),
0,
KEY_WRITE,
&hKey) != ERROR_SUCCESS)
return false;
char mszDNS[100];
strncpy(mszDNS, pDNS, 98);
int nDNS;
nDNS = strlen(mszDNS);
*(mszDNS + nDNS + 1) = 0x00; // REG_MULTI_SZ need add one more 0
nDNS += 2;
RegSetValueEx(hKey, "NameServer", 0, REG_SZ, (unsigned char*)mszDNS, nDNS);
RegCloseKey(hKey);
return true;
}
相关文章:
- 正在VS调试器中监视映射条目
- C++,指针数组,指向双链表中的条目
- Qt:当QListView获得新条目时,如何更新QStringList
- 使用cpp中的结构和函数的多个学生条目
- 两个 COM 组件中 ENUM 的重复条目
- 选择和修改嵌套向量中的条目的最佳实践
- C++:当所有条目都保证是唯一时,替代 std::map
- libcurl 和 DNS ttl 中的内部连接管理
- 将条目添加到双端 c++
- 为什么当我尝试搜索双链表中第一个数据条目之外的数据时,程序崩溃了?
- 如何在目录迭代器中选择特定的目录条目
- 基于文件中的条目创建对象
- DNS 查询格式标头结构中的小字节序问题
- C++ 为每个结构{人}条目创建文件
- 我的C++程序只写入文本文件最后一个条目
- 将结构数组中的某个条目传递到函数中
- 特征::向量;在函数中使用 Eigen::Matrix3f 的值初始化向量,大于 4 个条目
- 我该如何编码,使计算机知道两个名称条目和三个名称条目之间的区别
- 如何为DNS查找反向IPv6地址-C++
- 在网络适配器中添加DNS条目