NPSNotifyRegister

DWORD NPSNotifyRegister(
      enum NOTIFYTYPE NotifyType,
      NOTIFYCALLBACK NotifyCallBack
  );
 
NotifyType
The type of notification. This takes the values:
NotifyAddConnection For adding connections.
NotifyCancelConnection For canceling connections.
NotifyGetConnectionPerformance For get connection performance estimates.

NotifyCallBack
The notification function to be called back in the context of the application making the WNet request. A different callback address should be given for each type of notification registered.
WN_BAD_VALUE NotifyType is not a valid operation type, or NotifyCallBack is NULL.
WN_OUT_OF_MEMORY MPR is out of memory, so the notification function was not registered.

The notification function takes the same form for notification of all operations:

DWORD  (FAR PASCAL *NOTIFYCALLBACK) pfNotifyCallback(
  LPNOTIFYINFO lpNotifyInfo, 
  LPVOID lpOperationInfo 
  );
 
lpNotifyInfo Generic notification information common to all types of operation.
lpOperationInfo Pointer to a structure containing information specific to the operation being attempted. The structure is given below for each type of notification function.

Returns WN_SUCCESS - the notification was processed without error. If dwNotifyStatus has the NOTIFY_PRE flag set, the operation will be attempted and *pfNotifyCallback called again with the NOTIFY_POST flag set in dwNotifyStatus. The return status in dwOperationStatus is returned to the user.

WN_RETRY The operation failed and the notification function wants a retry. The operation will be retried by MPR and the pre-notification is not done a second time to this NP. This value should not be returned when being pre-notified or post-notified of a successful operation (if it is, it will be treated as WN_SUCCESS).
WN_CANCEL The user canceled the operation in some user interface produced within *pfNotifyCallback. WN_CANCEL is returned to the caller and a subsequent post-notification is not done to this NP, so any memory allocated for the context should be freed by the NP. This value should not be returned when being post-notified of a successful operation (if it is, it will be treated as WN_SUCCESS).

Any other value is returned to the caller as the result of the operation attempt (unless in post-notification of a successful operation, in which case it is ignored), so should only be returned if there was some internal error in the notify function (such as WN_OUT_OF_MEMORY) or to alter the error return status code to the caller. If an error is returned in pre-notification, post-notification is not done to this NP. When in post-notification and an error is returned, NPSSetCustomText or NPSSetExtendedError may be called to specify the error text, but SetLastError does not need to be explicitly called.