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