The 4th argument of DnsQuery PVOID pExtra accepts PIP4_ARRAY , containing the specified DNS servers to be queried. This is combined with the third argument DWORD Options DNS_QUERY_BYPASS_CACHE to bypass the cache receiver.
This works with Windows 2000, and in Windows XP DnsQuery calls a function called privateNarrowToWideQuery (in dnsapi.dll) and takes the argument pExtra as PIP4_ARRAY.
In this regard, the MSDN is inaccurate, which leads to the fact that this is an undocumented function. In older versions of the DnsQuery Call pExtra API call, pExtra was called aipServers .
As for the IPAA6 AAAA DNS records, you can try the function with the second WORD wType argument as DNS_TYPE_AAAA and the fifth PDNS_RECORD *ppQueryResultsSet as a pointer to DNS_AAAA_DATA . Although this still forces you to transfer the IP address of the IP address, not IPV6.
For Windows version support for IPV6 requests, see the following links
In future versions of Windows, I believe that the correct way to do this for IPV6 would be to use DnsQueryEx , with its first argument PDNS_QUERY_REQUEST pQueryRequest , which contains the member PDNS_ADDR_ARRAY pDnsServerList; which contains a member of the WORD Family; which determines the type of IP address of the DNS server.
If DnsQuery already supports a pointer to PDNS_ADDR_ARRAY as an argument for PVOID pExtra or will be changed in future versions of Windows for this, I'm not sure, but you can try and take a look.
See How to use the DnsQuery function to resolve host names and host addresses with Visual C ++ .NET for sample code, as you have already discovered.
Also see the following similar SO question .
source share