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;
}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值