Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Disconnect modem from app

Disconnect modem from app

Scheduled Pinned Locked Moved C / C++ / MFC
databasecomtutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • RaviBeeR Offline
    RaviBeeR Offline
    RaviBee
    wrote on last edited by
    #1

    Does anyone know how to close a modem connection? The connection was opened by the user, so I don't have a handle to it. But my app needs to hang up the modem when it terminates. Afterthought: I guess I need to query the state of the list of RAS connections and hang up the one that's active. Have to go find some RAS code at CP... /ravi Let's put "civil" back into "civilization" http://www.ravib.com ravib@ravib.com

    P 1 Reply Last reply
    0
    • RaviBeeR RaviBee

      Does anyone know how to close a modem connection? The connection was opened by the user, so I don't have a handle to it. But my app needs to hang up the modem when it terminates. Afterthought: I guess I need to query the state of the list of RAS connections and hang up the one that's active. Have to go find some RAS code at CP... /ravi Let's put "civil" back into "civilization" http://www.ravib.com ravib@ravib.com

      P Offline
      P Offline
      Peter Occil
      wrote on last edited by
      #2

      I wrote a function that disconnects the modem:

      #include <windows.h>
      #include <ras.h>

      void HangUp(){
      RASCONN *rasc=malloc(1000);
      DWORD bs,nc,i,j,dwRet;
      RASCONNSTATUS rcs;
      MSG msg;
      TCHAR s[257];
      rcs.dwSize=160;
      rasc->dwSize=412;
      dwRet=RasEnumConnections(rasc,&bs,&nc);
      if(!bs)return;
      rasc=realloc(rasc,bs);
      if(RasEnumConnections(rasc,&bs,&nc))
      return;
      for(i=0;i<bs/412;i++){
      HRASCONN hrc=rasc[i].hrasconn;
      dwRet = RasGetConnectStatus(hrc, &rcs);
      if (dwRet != ERROR_INVALID_HANDLE){
      RasHangUp(hrc);
      while (dwRet != ERROR_INVALID_HANDLE){
      while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){
      TranslateMessage(&msg);
      DispatchMessage(&msg);
      }
      dwRet = RasGetConnectStatus(hrc, &rcs);
      }
      }
      }
      free(rasc);
      }


      Peter O.

      RaviBeeR 1 Reply Last reply
      0
      • P Peter Occil

        I wrote a function that disconnects the modem:

        #include <windows.h>
        #include <ras.h>

        void HangUp(){
        RASCONN *rasc=malloc(1000);
        DWORD bs,nc,i,j,dwRet;
        RASCONNSTATUS rcs;
        MSG msg;
        TCHAR s[257];
        rcs.dwSize=160;
        rasc->dwSize=412;
        dwRet=RasEnumConnections(rasc,&bs,&nc);
        if(!bs)return;
        rasc=realloc(rasc,bs);
        if(RasEnumConnections(rasc,&bs,&nc))
        return;
        for(i=0;i<bs/412;i++){
        HRASCONN hrc=rasc[i].hrasconn;
        dwRet = RasGetConnectStatus(hrc, &rcs);
        if (dwRet != ERROR_INVALID_HANDLE){
        RasHangUp(hrc);
        while (dwRet != ERROR_INVALID_HANDLE){
        while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){
        TranslateMessage(&msg);
        DispatchMessage(&msg);
        }
        dwRet = RasGetConnectStatus(hrc, &rcs);
        }
        }
        }
        free(rasc);
        }


        Peter O.

        RaviBeeR Offline
        RaviBeeR Offline
        RaviBee
        wrote on last edited by
        #3

        Thanks very much, Peter! /ravi Let's put "civil" back into "civilization" http://www.ravib.com ravib@ravib.com

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups