test case for iphlpapi GetNetworkParams, dns server list.

svn path=/trunk/; revision=7258
This commit is contained in:
Art Yerkes 2003-12-26 23:59:49 +00:00
parent c359123664
commit 2b28365c4e
2 changed files with 55 additions and 0 deletions

View file

@ -0,0 +1,23 @@
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = nameserverlist
#TARGET_SDKLIBS = iphlpapi.a ws2_32.a kernel32.a
TARGET_SDKLIBS = ws2_32.a kernel32.a ntdll.a
TARGET_OBJECTS = $(TARGET_NAME).o iphlpapi.o registry.o
TARGET_CFLAGS = -Wall -Werror -g
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,32 @@
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
#include <iphlpapi.h>
int main( int argc, char **argv ) {
ULONG OutBufLen = 0;
PFIXED_INFO pFixedInfo;
PIP_ADDR_STRING Addr;
GetNetworkParams(NULL, &OutBufLen);
pFixedInfo = malloc(OutBufLen);
if (!pFixedInfo) {
printf( "Failed to alloc %d bytes.\n", (int)OutBufLen );
return 1;
}
printf( "%d Bytes allocated\n", (int)OutBufLen );
GetNetworkParams(pFixedInfo,&OutBufLen);
for( Addr = &pFixedInfo->DnsServerList;
Addr;
Addr = Addr->Next ) {
printf( "%c%s\n",
Addr == pFixedInfo->CurrentDnsServer ? '*' : ' ',
Addr->IpAddress.String );
}
free( pFixedInfo );
return 0;
}