Disconnect a Dial Up Networking?

Can somebody provide some code by which one can disconnect an existing dial-up-connection?
Who is Participating?
jhanceConnect With a Mentor Commented:
If you know the handle to the connection, just call RasHangUp() on it.  If you don't know the handle, you can use the following function to close all of them:

void CloseAllConnections()
      HRASCONN hrc;

      DWORD dwBufSize, dwNumConnections;

      LPRASCONN plpRasConn;
      plpRasConn = new RASCONN[32];

      plpRasConn[0].dwSize = sizeof(RASCONN);
      dwBufSize = 32 * sizeof(RASCONN);

      if(RasEnumConnections(plpRasConn, &dwBufSize, &dwNumConnections) != 0){
            AfxMessageBox("ERROR", MB_OK);

      for(DWORD i=0; i<dwNumConnections; i++){
            hrc = plpRasConn[i].hrasconn;

      delete [] plpRasConn;
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.