//
// Link with IPHlpAPI.lib
//
#include <stdio.h>
#include <windows.h>
#include <iphlpapi.h>
#pragma comment(lib, "iphlpapi.lib")
int 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 );
}
// Link with IPHlpAPI.lib
//
#include <stdio.h>
#include <windows.h>
#include <iphlpapi.h>
#pragma comment(lib, "iphlpapi.lib")
int 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 );
}