Platform SDK: Internet Protocol Helper

AddIPAddress

The AddIPAddress function adds the specified IP address to the specified adapter.

DWORD AddIPAddress(
  IPAddr Address,        // IP address to add
  IPMask IpMask,         // subnet mask for IP address
  DWORD IfIndex,         // index of adapter
  PULONG NTEContext,     // Net Table Entry context
  PULONG NTEInstance     // Net Table Entry Instance
);

Parameters

Address
Specifies the IP address to add to the adapter.
IpMask
Specifies the subnet mask for the IP address.
IfIndex
Specifies the adapter to which to add the address.
NTEContext
Pointer to a ULONG variable that, on successful return, points to the Net Table Entry (NTE) context for this IP address. The caller can later use this context in a call to DeleteIPAddress.
NTEInstance
Pointer to a ULONG variable that, on successful return, points to the NTE instance for this IP address.

Return Values

If the function succeeds, the return value is NO_ERROR.

If the function fails, use FormatMessage to obtain the message string for the returned error.

Remarks

For information about the IPAddr and IPMask data types, see Win32 Simple Data Types. To convert an IP address between dotted decimal notation and IPAddr format, use the inet_addr and inet_ntoa functions.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Unsupported.
  Header: Declared in Iphlpapi.h.
  Library: Use Iphlpapi.lib.

See Also

DeleteIPAddress, GetAdapterIndex