随笔 - 74, 文章 - 0, 评论 - 26, 引用 - 0
数据加载中……

windows mobile 关闭gprs连接

unsigned int CloseRasGPRSConnections()
{
     int index; // An integer index
     DWORD dwError, dwRasConnSize, dwNumConnections; // Number of connections found
     RASCONN RasConn[20]; // Buffer for connection state data,Assume the maximum number of entries is 20.
    BOOL RETURN_VALUE=0;
    WCHAR *MySelectNetName;

     // Assume no more than 20 connections.
     RasConn[0].dwSize = sizeof (RASCONN);
     dwRasConnSize = 20 * sizeof (RASCONN);

     // Find all connections.
     if (dwError = RasEnumConnections (RasConn, &dwRasConnSize,&dwNumConnections))
     {
          return -1;
     }

     // If there are no connections, return zero.
     if (!dwNumConnections)
     {
          return 0;
     }

     // Terminate all of the remote access connections.
     GetConnectionStatus();
    //here add to get selected network
    MySelectNetName=GetMMSSelectNet();
   
    GPRSServerName* P_CMWAPtemp=pCMWAP_backup;
     for (index = 0; index < (int)dwNumConnections; ++index)
     {
         while( P_CMWAPtemp )
         {
              if(!wcscmp(RasConn[index].szEntryName,P_CMWAPtemp->ServerName)||
                !wcscmp(RasConn[index].szEntryName, MySelectNetName))
              {
                   if (dwError = RasHangUp (RasConn[index].hrasconn))
                       
                        RETURN_VALUE=-1;
                   else
                           //successfully disconnect cmwap;
                        RETURN_VALUE=0;
              }
            P_CMWAPtemp = P_CMWAPtemp->pnext ;
          }
     }
    //free mem
     freelink(pCMWAP_backup);
     return RETURN_VALUE;
}


posted on 2007-11-22 12:59 井泉 阅读(1723) 评论(1)  编辑 收藏 引用 所属分类: C++

评论

# re: windows mobile 关闭gprs连接  回复  更多评论   

RasEnumConnections 在有些机器上不能用,有好的解决方法吗

What are you trying to accomplish? You can find an existing RAS connection
using RAS API. However, it is much harder task to find all active
connections (Ethernet, M/PDP GPRS etc.)

--
Yaroslav Goncharov
Pocket PC Developer Network coordinator, http://pocketpcdn.com
Spb Software House, http://spbsoftwarehouse.com

Thanks
2008-02-18 17:24 | jacky lee

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理