实现windows下的动态域名解析服务(三)

  通过dns api实现动态域名更新,下面详细介绍典型的dns api函数用法,更多的dns api函数用法请参考微软最新的msdn知识库(vc2003,vc2005带有dns api库文件,vc6.0需手动复制windns.h,dnsapi.lib两个文件到vc安装文件夹的include和lib文件夹中,或者安装最新的sdk包,需要这两个文件的朋友可以联系我,我的邮箱:world7th@163.com)

 主要介绍如下几个api函数:

  DnsQuery,DnsRecordListFree,DnsRecordCopyEx,DnsModifyRecordsInSet

这里首先给出msdn中这些函数的原文说明

1.DnsQuery

The DnsQuery function type is the generic query interface to the DNS namespace, and provides application developers with a DNS query resolution interface. Like many DNS functions, the DnsQuery function type is implemented in multiple forms to facilitate different character encoding.

Based on the character encoding involved, use one of the following functions:

DnsQuery_A (for ANSI encoding)
DnsQuery_W (for Unicode encoding)
DnsQuery_UTF8 (for UTF-8 encoding)
If the DnsQuery function type is called without its suffix (_A, _W, or _UTF8), a compiler error will occur.


DNS_STATUS WINAPI DnsQuery(
  PCSTR lpstrName,
  WORD wType,
  DWORD fOptions,
  PVOID pExtra,
  PDNS_RECORD* ppQueryResultsSet,
  PVOID* pReserved
);

Parameters
lpstrName
[in] The name of the owner of the record set that is queried.
wType
[in] The numeric representation of the type of record set that is queried, such as a value of 1 (0x0001) for an A record (DNS_TYPE_A). For more information and a complete listing of record set types and their numeric representations, see the Windns.h header file.
fOptions
[in] The query options. Options can be combined and all options override DNS_QUERY_STANDARD. The following table lists the available query options.Query Meaning
DNS_QUERY_STANDARD Standard query.
DNS_QUERY_ACCEPT_TRUNCATED_RESPONSE Returns truncated results. Does not retry under TCP.
DNS_QUERY_USE_TCP_ONLY Uses TCP only for the query.
DNS_QUERY_NO_RECURSION Directs the DNS server to perform an iterative query (specifically directs the DNS server not to perform recursive resolution to resolve the query).
DNS_QUERY_BYPASS_CACHE Bypasses the resolver cache on the lookup.
DNS_QUERY_NO_WIRE_QUERY Directs DNS to perform a query on the local cache only.
Windows 2000 Server and Windows 2000 Professional:  This value is not supported. For similar functionality, use DNS_QUERY_CACHE_ONLY.
DNS_QUERY_NO_LOCAL_NAME Directs DNS to ignore the local name.
Windows 2000 Server and Windows 2000 Professional:  Th

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值