次の方法で共有


NotifyAddrChange (Compact 2013)

3/26/2014

This function causes a notification to be sent to the caller when a change occurs in the table that maps IP addresses to interfaces.

Syntax

DWORD NotifyAddrChange(
  PHANDLE Handle, 
  LPOVERLAPPED overlapped 
);

Parameters

  • Handle
    [in] A pointer to a HANDLE variable that receives a file handle for use in a later call to the GetOverlappedResult function.

    Warning Do not close this handle, and do not associate it with a completion port.

  • overlapped
    [in] A pointer to an OVERLAPPED structure that notifies the caller of any changes in the table that maps IP addresses to interfaces.

Return Value

If the function succeeds, the return value is NO_ERROR if the caller specifies NULL for the Handle and overlapped parameters. If the caller specifies non-NULL parameters, the return value for success is ERROR_IO_PENDING.

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

Return code

Description

ERROR_CANCELLED

The context is being deregistered. So, the call was canceled immediately.

ERROR_INVALID_PARAMETER

An invalid parameter was passed. This error is returned if the both the Handle and overlapped parameters are not NULL, but the memory specified by the input parameters cannot be written by the calling process. This error is also returned if the client already has made a change notification request, so this duplicate request will fail.

ERROR_NOT_ENOUGH_MEMORY

There was insufficient memory available to complete the operation.

ERROR_NOT_SUPPORTED

This error is returned on versions of Windows where this function is not supported.

Remarks

The NotifyAddrChange function may be called in two ways:

  • Synchronous method
  • Asynchronous method

If the caller specifies NULL for the Handle and overlapped parameters, the call to NotifyAddrChange is synchronous and will block until an IP address change occurs. In this case if a change occurs, the NotifyAddrChange function completes to indicate that a change has occurred.

If the NotifyAddrChange function is called synchronously, a notification will be sent on the next IPv4 address change until the application terminates.

If the caller specifies a handle variable and an OVERLAPPED structure, the NotifyAddrChange function call is asynchronous and the caller can use the returned handle with the OVERLAPPED structure to receive asynchronous notification of IPv4 address changes by using the GetOverlappedResult function. See the following topics for information about how to use the handle and OVERLAPPED structure to receive notifications:

  • Synchronization and Overlapped Input and Output
  • GetOverlappedResult

The CancelIPChangeNotify function cancels notification of IPv4 address and route changes previously requested with successful calls to the NotifyAddrChange or NotifyRouteChange functions.

As soon as an application has been notified of a change, the application can then call the GetIpAddrTable or GetAdaptersAddresses function to retrieve the table of IPv4 addresses to determine what has changed. If the application is notified and requires notification for the next change, the NotifyAddrChange function must be called again.

If the NotifyAddrChange function is called asynchronously, a notification will be sent on the next IPv4 address change until either the application cancels the notification by calling the CancelIPChangeNotify function or the application terminates. If the application terminates, the system will automatically cancel the registration for the notification. It is still recommended that an application explicitly cancel any notification before it terminates.

Any registration for a notification does not persist across a system shut down or restart.

Requirements

Header

iphlpapi.h

Library

Iphlpapi.lib

See Also

Reference

IP Helper Functions
CancelIPChangeNotify
GetAdaptersAddresses
GetIpAddrTable
NotifyIpInterfaceChange
NotifyRouteChange

Other Resources

IP Helper