afalvey
asked on
Anyone have a C++ example of RasEnumConnections implementation?
Anyone have a C++ example of RasEnumConnections implementation? Also, how would you iterate through the returned connections to see if the connection you are trying to make is already connected?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I've been trying this but I always get the default: state even when I'm connected. Any suggestions?
LPRASENTRYNAME RasEntry;
DWORD Buffer;
DWORD Entry;
DWORD Retrn;
DWORD Index;
Buffer = sizeof(RASENTRYNAME);
//RasEntry->dwSize = sizeof(RASENTRYNAME);
Retrn = RasENUMENTRIES( NULL, NULL, RasEntry, &Buffer, &Entry );
//the buffer is too small
if (Retrn == 603)
{
RasEntry->dwSize = sizeof(RASENTRYNAME);
Retrn = RasENUMENTRIES( NULL, NULL, RasEntry, &Buffer, &Entry );
}
if ( Retrn != 0 ) //error
{
m_IAmConnected = FALSE;
FireErrorLaunchingDialUpAc count(m_St ringResour ce->LoadSt ring(ERR_C OMM_ERROR_ LAUNCHING_ DIAL_UP_AC COUNT));
}
if ( Retrn == 0 ) // no errors
{
for ( Index = 0; Index < Entry; Index++ )
{
if (rdParams.szEntryName == RasEntry[Index].szEntryNam e);
{
//get connection status for this entry
RASCONNSTATUS ConnectionStatus;
ConnectionStatus.dwSize = sizeof(RASCONNSTATUS);
RasCONNECTSTATUS(m_hRasCon n, // handle to RAS connection of interest
&ConnectionStatus); // buffer to receive status data
switch( ConnectionStatus.rasconnst ate )
{
case RASCS_Connected:
m_IAmConnected = TRUE;
//dial-up failed
case RASCS_Disconnected:
m_IAmConnected = FALSE;
default:
m_IAmConnected = FALSE;
}
}
}
}
LPRASENTRYNAME RasEntry;
DWORD Buffer;
DWORD Entry;
DWORD Retrn;
DWORD Index;
Buffer = sizeof(RASENTRYNAME);
//RasEntry->dwSize = sizeof(RASENTRYNAME);
Retrn = RasENUMENTRIES( NULL, NULL, RasEntry, &Buffer, &Entry );
//the buffer is too small
if (Retrn == 603)
{
RasEntry->dwSize = sizeof(RASENTRYNAME);
Retrn = RasENUMENTRIES( NULL, NULL, RasEntry, &Buffer, &Entry );
}
if ( Retrn != 0 ) //error
{
m_IAmConnected = FALSE;
FireErrorLaunchingDialUpAc
}
if ( Retrn == 0 ) // no errors
{
for ( Index = 0; Index < Entry; Index++ )
{
if (rdParams.szEntryName == RasEntry[Index].szEntryNam
{
//get connection status for this entry
RASCONNSTATUS ConnectionStatus;
ConnectionStatus.dwSize = sizeof(RASCONNSTATUS);
RasCONNECTSTATUS(m_hRasCon
&ConnectionStatus); // buffer to receive status data
switch( ConnectionStatus.rasconnst
{
case RASCS_Connected:
m_IAmConnected = TRUE;
//dial-up failed
case RASCS_Disconnected:
m_IAmConnected = FALSE;
default:
m_IAmConnected = FALSE;
}
}
}
}
You have no "break;" in your "case:" statements!!!!!
switch( ConnectionStatus.rasconnst ate )
{
case RASCS_Connected:
m_IAmConnected = TRUE;
break;
//dial-up failed
case RASCS_Disconnected:
m_IAmConnected = FALSE;
break;
default:
m_IAmConnected = FALSE;
}
switch( ConnectionStatus.rasconnst
{
case RASCS_Connected:
m_IAmConnected = TRUE;
break;
//dial-up failed
case RASCS_Disconnected:
m_IAmConnected = FALSE;
break;
default:
m_IAmConnected = FALSE;
}
ras.h and raserror.h?