//HRASCONN tempH;为全局变量//
  if((Ret=RasDial(NULL,NULL,&RasParams,0,NULL,&tempH))!=0)
  {   
  RasHangUp(tempH);
  
  CString RasMessageStr;
  RasGetErrorString((UINT)Ret,szRasString,256);
  ErrorStr.Format("%s",szRasString);
  if(OutFunc!=NULL)
   OutFunc(telBook,M_MODEMSTATE,(WPARAM)&ErrorStr,ErrorStr.GetLength());
  return false;
  }

解决方案 »

  1.   

    RasDial调用之间是需要延迟一段时间才能再次调用
      

  2.   

    you should close all RAS connections and restart .
    BOOL CloseAllRASConnections()
    {
     TRACE0("CloseAllRASConnections()\n");
     BOOL bReturn = FALSE;
     CRas ras;
     if(ras.Init())
     {
      DWORD dwConnections = 0L;
      DWORD dwCount  = sizeof(RASCONN) * MAX_RAS_CONNS;  RASCONN RasConn[MAX_RAS_CONNS];
      RasConn->dwSize  = sizeof(RASCONN);  // get all active connections
      DWORD nRet = ras.EnumConnections( RasConn, &dwCount, &dwConnections);
      if (nRet != 0)
      {
       TRACE1("RasEnumConnections failed: Error = %d\n", nRet);
      }
      else
      {
       TRACE0("The following RAS connections are currently active and will be
    closed\n");   for (DWORD i = 0; i < dwConnections; i++)
       {
        TRACE1("Entry name: %s\n", RasConn[i].szEntryName);    // close each active connection
        nRet = ras.HangUp( RasConn[i].hrasconn);
        if(nRet != 0)
         TRACE2("HangUp[#%i] failed: Error = %d", i, nRet);    file://sleep 3 sec to give the modem some time to respond
        Sleep(3 * 1000);
       }   bReturn = TRUE;
      }
     } return bReturn;
    }