//#include<Winsock2.h>
//#include<Iphlpapi.h>
//#include<Ndis.h>
PIP_ADAPTER_INFO pAdapterInfo;
PIP_ADAPTER_INFO pAdapter = NULL;
DWORD dwRetVal = 0;
pAdapterInfo= (IP_ADAPTER_INFO *) malloc( sizeof(IP_ADAPTER_INFO) );
ULONG ulOutBufLen = sizeof(IP_ADAPTER_INFO);
// Make an initial call to GetAdaptersInfo to get
// the necessary size into the ulOutBufLen variable
if (GetAdaptersInfo( pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) {
free(pAdapterInfo);
pAdapterInfo = (IP_ADAPTER_INFO *) malloc (ulOutBufLen);
}
if ((dwRetVal = GetAdaptersInfo( pAdapterInfo, &ulOutBufLen)) == NO_ERROR) {
pAdapter = pAdapterInfo;
while (pAdapter) {
printf("/tAdapter Name: /t%s/n", pAdapter->AdapterName);
printf("/tAdapter Desc: /t%s/n", pAdapter->Description);
printf("/tAdapter Addr: /t%ld/n", pAdapter->Address);
printf("/tIP Address: /t%s/n", pAdapter->IpAddressList.IpAddress.String);
printf("/tIP Mask: /t%s/n", pAdapter->IpAddressList.IpMask.String);
printf("/tGateway: /t%s/n", pAdapter->GatewayList.IpAddress.String);
printf("/t***/n");
if (pAdapter->DhcpEnabled) {
printf("/tDHCP Enabled: Yes/n");
printf("/t/tDHCP Server: /t%s/n", pAdapter->DhcpServer.IpAddress.String);
printf("/tLease Obtained: %ld/n", pAdapter->LeaseObtained);
}
else
printf("/tDHCP Enabled: No/n");
if (pAdapter->HaveWins) {
printf("/tHave Wins: Yes/n");
printf("/t/tPrimary Wins Server: /t%s/n", pAdapter->PrimaryWinsServer.IpAddress.String);
printf("/t/tSecondary Wins Server: /t%s/n", pAdapter->SecondaryWinsServer.IpAddress.String);
}
else
printf("/tHave Wins: No/n");
pAdapter = pAdapter->Next;
}
}
else {
printf("Call to GetAdaptersInfo failed./n");
}