Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.5 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h>
  3. #include <nturtl.h>
  4. #include <windows.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <dnsapi.h>
  8. VOID
  9. PrintIpAddress (
  10. IN DWORD dwIpAddress );
  11. _cdecl
  12. main(int argc, char **argv)
  13. {
  14. DWORD iter;
  15. DWORD Count;
  16. PIP_ARRAY pIpAddresses = NULL;
  17. printf( "Get the local IP address list\n" );
  18. Count = DnsGetIpAddressList( &pIpAddresses );
  19. if ( Count && pIpAddresses )
  20. {
  21. printf( "\n Ip Addresses :\n" );
  22. for ( iter = 0; iter < pIpAddresses->cAddrCount; iter++ )
  23. {
  24. printf( " (%d) \t", iter+1 );
  25. PrintIpAddress( pIpAddresses->aipAddrs[iter] );
  26. }
  27. LocalFree( pIpAddresses );
  28. }
  29. else
  30. {
  31. printf( "\n No Ip Addresses found.\n" );
  32. }
  33. printf( "\n\nGet the local DNS server list\n" );
  34. Count = DnsGetDnsServerList( &pIpAddresses );
  35. if ( Count && pIpAddresses )
  36. {
  37. printf( "\n Ip Addresses :\n" );
  38. for ( iter = 0; iter < pIpAddresses->cAddrCount; iter++ )
  39. {
  40. printf( " (%d) \t", iter+1 );
  41. PrintIpAddress( pIpAddresses->aipAddrs[iter] );
  42. }
  43. LocalFree( pIpAddresses );
  44. }
  45. else
  46. {
  47. printf( "\n No Ip Addresses found.\n" );
  48. }
  49. return(0);
  50. }
  51. VOID
  52. PrintIpAddress (
  53. IN DWORD dwIpAddress )
  54. {
  55. printf( " %d.%d.%d.%d\n",
  56. ((BYTE *) &dwIpAddress)[0],
  57. ((BYTE *) &dwIpAddress)[1],
  58. ((BYTE *) &dwIpAddress)[2],
  59. ((BYTE *) &dwIpAddress)[3] );
  60. }