如何编程实现添加和删除dns server,如何自动获取dns server.

broaden 2003-10-20 06:16:08

在windows中可以通过对连接属性的设置来手动增加和去掉dns server,也可以自动获取dns server。那编程如何实现呢?
...全文
116 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
broaden 2003-10-29
  • 打赏
  • 举报
回复
有人知道吗?
broaden 2003-10-24
  • 打赏
  • 举报
回复
CloudWater(秋云开水) :

大哥,我问的是DNS(domain name server),你好想看错了吧。不过还是感谢你的热心。
CloudWater 2003-10-23
  • 打赏
  • 举报
回复
Private Sub Command1_Click()

Dim DataSourceName As String
Dim DatabaseName As String
Dim Description As String
Dim DriverPath As String
Dim DriverName As String
Dim LastUser As String
Dim Regional As String
Dim Server As String

Dim lResult As Long
Dim hKeyHandle As Long

'Specify the DSN parameters.

DataSourceName = "<the name of your new DSN>"
DatabaseName = "<name of the database to be accessed by the new DSN>"
Description = "<a description of the new DSN>"
DriverPath = "<path to your SQL Server driver>"
LastUser = "<default user ID of the new DSN>"
Server = "<name of the server to be accessed by the new DSN>"
DriverName = "SQL Server"

'Create the new DSN key.

lResult = RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBC.INI\" & _
DataSourceName, hKeyHandle)

'Set the values of the new DSN key.

lResult = RegSetValueEx(hKeyHandle, "Database", 0&, REG_SZ, _
ByVal DatabaseName, Len(DatabaseName))
lResult = RegSetValueEx(hKeyHandle, "Description", 0&, REG_SZ, _
ByVal Description, Len(Description))
lResult = RegSetValueEx(hKeyHandle, "Driver", 0&, REG_SZ, _
ByVal DriverPath, Len(DriverPath))
lResult = RegSetValueEx(hKeyHandle, "LastUser", 0&, REG_SZ, _
ByVal LastUser, Len(LastUser))
lResult = RegSetValueEx(hKeyHandle, "Server", 0&, REG_SZ, _
ByVal Server, Len(Server))

'Close the new DSN key.

lResult = RegCloseKey(hKeyHandle)

'Open ODBC Data Sources key to list the new DSN in the ODBC Manager.
'Specify the new value.
'Close the key.

lResult = RegCreateKey(HKEY_LOCAL_MACHINE, _
"SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources", hKeyHandle)
lResult = RegSetValueEx(hKeyHandle, DataSourceName, 0&, REG_SZ, _
ByVal DriverName, Len(DriverName))
lResult = RegCloseKey(hKeyHandle)

End Sub
bpint 2003-10-23
  • 打赏
  • 举报
回复
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{x-x-x-x-x}里面找找相关的键值:
EnableDHCP
NameServer
broaden 2003-10-23
  • 打赏
  • 举报
回复
人都去那里了?
broaden 2003-10-20
  • 打赏
  • 举报
回复
没人知道?

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧