|
DWORD GetNetworkParams (
PFIXED_INFO pFixedInfo,
PULONG pOutBufLen
);
#include <stdio.h>
#include <windows.h>
#include <iphlpapi.h>
#program comment (lib, "iphlpapi.lib")
main () {
FIXED_INFO * FixedInfo;
ULONG ulOutBufLen;
DWORD dwRetVal;
IP_ADDR_STRING * pIPAddr;
FixedInfo = (FIXED_INFO *) GlobalAlloc (GPTR, sizeof (FIXED_INFO));
ulOutBufLen = sizeof (FIXED_INFO);
if (ERROR_BUFFER_OVERFLOW == GetNetworkParams (FixedInfo,&ulOutBufLen)) {
GlobalFree (FixedInfo);
FixedInfo = (FIXED_INFO *) GlobalAlloc (GPTR, ulOutBufLen);
}
if (dwRetVal = GetNetworkParams (FixedInfo,&ulOutBufLen)) {
printf ("Call to GetNetworkParams failed. Return Value:% 08x\n", dwRetVal);
}
else {
printf ("Host Name:% s\n", FixedInfo-> HostName);
printf ("Domain Name:% s\n", FixedInfo-> DomainName);
printf ("DNS Servers:\n");
printf ("\t% s\n", FixedInfo-> DnsServerList.IpAddress.String);
pIPAddr = FixedInfo-> DnsServerList.Next;
while (pIPAddr) {
printf ("\t% s\n", pIPAddr-> IpAddress.String);
pIPAddr = pIPAddr-> Next;
}
}
exit (0);
}
To install sdk |
|