ReactOS  0.4.15-dev-1201-gb2cf5a4
dnsquery.c
Go to the documentation of this file.
1 #include <windows.h>
2 #include <stdio.h>
3 #include <winerror.h>
4 #include <windns.h>
5 #include <assert.h>
6 
7 int main( int argc, char **argv ) {
8  PDNS_RECORD QueryReply, AddrResponse;
9  DWORD Addr;
10 
11  assert (DnsQuery ("www.reactos.com", DNS_TYPE_A, DNS_QUERY_STANDARD,
12  NULL, &QueryReply, NULL) == ERROR_SUCCESS);
13  AddrResponse = QueryReply;
14  while( AddrResponse ) {
15  if( AddrResponse->wType == DNS_TYPE_A ) {
16  Addr = ntohl( AddrResponse->Data.A.IpAddress );
17  printf( "www.reactos.com == %d.%d.%d.%d\n",
18  (int)(Addr >> 24) & 0xff,
19  (int)(Addr >> 16) & 0xff,
20  (int)(Addr >> 8) & 0xff,
21  (int)Addr & 0xff );
22  }
23  AddrResponse = AddrResponse->pNext;
24  }
25  DnsRecordListFree( QueryReply, DnsFreeRecordList );
26 
27  return 0;
28 }
static int argc
Definition: ServiceArgs.c:12
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DNS_TYPE_A
Definition: windns.h:41
#define assert(x)
Definition: debug.h:53
#define argv
Definition: mplay32.c:18
VOID WINAPI DnsRecordListFree(PDNS_RECORD list, DNS_FREE_TYPE type)
Definition: record.c:526
#define DnsQuery
Definition: windns.h:938
smooth NULL
Definition: ftsmooth.c:416
int main(int argc, char **argv)
Definition: dnsquery.c:7
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DNS_QUERY_STANDARD
Definition: windns.h:8
#define PDNS_RECORD
Definition: windns.h:636
#define printf
Definition: config.h:203
#define ntohl(x)
Definition: module.h:203