Unless I'm missing something (I haven't a Windows box handy to compile this, so forgive me if I am) your code is incorrect. Personally i wouldn't do this with a smart pointer, since all you're essentially using it for is a custom janitor class (and you could write one of those easy-enough).
Regardless, first, your deleter should be :
auto pdnsDeleter = [&](PDNS_RECORD ptr){ if (ptr) DnsRecordListFree(ptr, DnsFreeRecordList); };
Next, the type of your smart pointer should be:
std::unique_ptr<DNS_RECORD, decltype(pdnsDeleter)> results;
Finally, I believe your loadup of this smart pointer should be after determination the function succeeded:
PDNS_RECORD pdnsrec;
if (DnsQuery(L"google.com", DNS_TYPE_A, DNS_QUERY_STANDARD, NULL, &pdnsrec, NULL))
{
results.reset(pdnsrec);
}
If I got that right, your deleter will be fired correctly on scope exit on the fetched chain. But again, this seems an awful lot of work for what you can effectively make simpler with your own janitor class.