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.
|
|
#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <dnsapi.h>
_cdecl main(int argc, char **argv) { DWORD cch, status ; WCHAR szName[256] ; REGISTER_HOST_STATUS RegisterStatus ; REGISTER_HOST_ENTRY RegisterEntries[3] ; char c;
if (argc != 2) { printf("Usage: dhcp <name>.\n") ; exit(1) ; }
printf("DHCP Async API Test\n") ;
if (!(RegisterStatus.hDoneEvent = CreateEventA(NULL, TRUE,FALSE,NULL))) { status = GetLastError(); printf("Cant create event.\n"); printf ("GetLastError() returned %x\n",status); exit(1) ; }
strcpy(szName, argv[1]);
RegisterEntries[0].Addr.ipAddr = 0x101 ; RegisterEntries[0].dwOptions = REGISTER_HOST_A ;
RegisterEntries[1].Addr.ipAddr = 0x101 ; RegisterEntries[1].dwOptions = REGISTER_HOST_A | REGISTER_HOST_PTR ;
RegisterEntries[2].Addr.ipAddr = 0x103 ; RegisterEntries[2].dwOptions = REGISTER_HOST_A | REGISTER_HOST_TRANSIENT ;
status = DnsAsyncRegisterHostAddrs(szName, RegisterEntries, 1, NULL, &RegisterStatus, 678) ;
if (status != NO_ERROR) {
printf("DnsAsyncRegisterHostAddrs failed immediately with %x.\n", status) ; exit(1) ; }
c = getchar();
status = WaitForSingleObject(RegisterStatus.hDoneEvent, INFINITE) ;
if (status != WAIT_OBJECT_0) {
printf("DnsAsyncRegisterHostAddrs failed with %x.\n",status) ; exit(1) ; } else {
printf("DnsAsyncRegisterHostAddrs completes with: %x.\n", RegisterStatus.dwStatus) ; }
// Sleep(100000) ;
}
|