Disconnecting a RAS Connection

When a client application starts a connection operation, the RasDial function call receives an HRASCONN connection handle to identify the connection. If the returned handle is not NULL, the client must eventually call the RasHangUp function to end the connection. If an error occurs during the connection operation, the client must call RasHangUp even though the connection was never established.

A client application might require a connection to end even though it does not have the handle returned by RasDial. For example, the application that called RasDial might have exited when the connection was established. In this case, the disconnecting application can use the RasEnumConnections function to get data on all current connections. For each connection, RasEnumConnections returns a RASCONN structure containing the HRASCONN connection handle and the phone-book entry name or phone number specified when the connection operation started. This data can be used to display a list of connections from which a user can select the connection to close.