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.

83 lines
1.9 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. _cdecl
  9. main(int argc, char **argv)
  10. {
  11. DWORD cch, status ;
  12. WCHAR szName[256] ;
  13. REGISTER_HOST_STATUS RegisterStatus ;
  14. REGISTER_HOST_ENTRY RegisterEntries[3] ;
  15. char c;
  16. if (argc != 2) {
  17. printf("Usage: dhcp <name>.\n") ;
  18. exit(1) ;
  19. }
  20. printf("DHCP Async API Test\n") ;
  21. if (!(RegisterStatus.hDoneEvent = CreateEventA(NULL, TRUE,FALSE,NULL))) {
  22. status = GetLastError();
  23. printf("Cant create event.\n");
  24. printf ("GetLastError() returned %x\n",status);
  25. exit(1) ;
  26. }
  27. strcpy(szName, argv[1]);
  28. RegisterEntries[0].Addr.ipAddr = 0x101 ;
  29. RegisterEntries[0].dwOptions = REGISTER_HOST_A ;
  30. RegisterEntries[1].Addr.ipAddr = 0x101 ;
  31. RegisterEntries[1].dwOptions = REGISTER_HOST_A | REGISTER_HOST_PTR ;
  32. RegisterEntries[2].Addr.ipAddr = 0x103 ;
  33. RegisterEntries[2].dwOptions = REGISTER_HOST_A | REGISTER_HOST_TRANSIENT ;
  34. status = DnsAsyncRegisterHostAddrs(szName,
  35. RegisterEntries,
  36. 1,
  37. NULL,
  38. &RegisterStatus,
  39. 678) ;
  40. if (status != NO_ERROR) {
  41. printf("DnsAsyncRegisterHostAddrs failed immediately with %x.\n",
  42. status) ;
  43. exit(1) ;
  44. }
  45. c = getchar();
  46. status = WaitForSingleObject(RegisterStatus.hDoneEvent, INFINITE) ;
  47. if (status != WAIT_OBJECT_0) {
  48. printf("DnsAsyncRegisterHostAddrs failed with %x.\n",status) ;
  49. exit(1) ;
  50. }
  51. else {
  52. printf("DnsAsyncRegisterHostAddrs completes with: %x.\n",
  53. RegisterStatus.dwStatus) ;
  54. }
  55. // Sleep(100000) ;
  56. }