Starts a new thread which monitors the system for RAS connections, whenever a connection is created or terminated the specified callback procedure is called.

RasConnectionNotificationEx(nRasConn, nFlags, cCallback)

Parameters

nRasConn

A handle to the RAS connection for which to receive the notification.
This can be a handle returned by the RasDialEx or ARasConnections.
If this parameter is INVALID_HANDLE_VALUE (-1), notifications are received for all RAS connections on the local client.

nFlags
One or a combition of the following values (defined in rasapi32.h).
ConstantDescription
RASCN_ConnectionIf nRasConn is INVALID_HANDLE_VALUE, a callback is made when any RAS connection is created.
RASCN_DisconnectionA callback is made when the nRasConn connection is terminated. If nRasConn is a multilink connection, the callback is made when all subentries are disconnected. If nRasConn is INVALID_HANDLE_VALUE, the callback is made when any RAS connection is terminated.
RASCN_BandwidthAddedWindows NT: If nRasConn is a handle to a combined multilink connection, the callback is made when a subentry is connected.
RASCN_BandwidthRemovedWindows NT: If nRasConn is a handle to a combined multilink connection, the callback is made when a subentry is disconnected.
cCallback

The name of a function to call when a RAS connection is created/terminated.
The function should have the following prototype.

FUNCTION OnConnectionChange(lnConn, lnError)
    IF lnError = 0
        && call ARasConnections to see if a new connection was established or one was disconnected
        LOCAL lnConnCount, laRasConns[1,5]
        lnConnCount = ARasConnections('laRasConns')
        IF ASCAN(laRasConns,lnConn,1,0,5,8) > 0
            ? "RAS connection", lnConn, "connected."
        ELSE
            ? "RAS connection", lnConn, "disconnected."
        ENDIF
    ELSE
        ? "WaitForMultipleObjects failed with errorcode", lnError
    ENDIF
ENDFUNC

Note

When monitoring a single active RAS connection, the notifications end automatically after it's disconnected.

Return Value

An handle to the thread monitoring the RAS connection.

See Also

Reference

AbortRasConnectionNotification
ARasConnections
ARasDevices
ARasPhonebookEntries
RasClearConnectionStatistics
RasDialDlgEx
RasDialEx
RasGetConnectStatusEx
RasHangUpEx
RasPhonebookDlgEx

Used WinApi functions

RasConnectionNotification
WaitForMultipleObjects
PostMessage