[Windows Mobile Development and Hacking General] knopper:
Hi,

I 'm not able to establish GPRS connection using RasDial on PPC 2005 . It returns always error 633. That means:

"The port is already in use or is not configured for Remote Access dialout.� (See related Microsoft article: ErrMsg: Error 633: The Modem Is Not Installed or Configured...) "

But it works fine in PPC 2003. Does anyone gets RAS API run successfull on WM 5.0 ?

here is my code:

void ConnectGPRSDlg::connectViaRAS()
{
RASDIALPARAMS rasDialParam;
BOOL bPasswd,bRasEntryFound;
DWORD dwRes, dwSize, dwEntries, dw;
short n_attempts = 5;
HRASCONN g_rasConn = NULL;
CString szError,msg,szResult;
LPRASENTRYNAME lpRasEntry = NULL;

// structure init.
memset(&rasDialParam, 0, sizeof(RASDIALPARAMS));
rasDialParam.dwSize = sizeof (RASDIALPARAMS);

lpRasEntry = new RASENTRYNAME[20];
if(lpRasEntry == NULL)
{
szError.Format( _T("Out of memory") );
msg += szError;
m_editbox.SetWindowTextW(msg);
return;
}

lpRasEntry[0].dwSize = sizeof(RASENTRYNAME);
dwSize = sizeof(RASENTRYNAME) * 20;
dwRes = RasEnumEntries(NULL, NULL, lpRasEntry,
&dwSize, &dwEntries);

if (dwRes != 0)
{
szError.Format( _T("Error getting RAS entries %d"),dwRes );
msg += szError;
}
else
{
szError.Format( _T("got RAS %d entries\r\n "),dwEntries );
msg += szError;
for(dw = 0; dw < dwEntries; dw++)
{
if( 0 == _tcscmp( lpRasEntry[dw].szEntryName, L"T-Mobile Internet" ) )
{
bRasEntryFound = TRUE;
_tcscpy( rasDialParam.szEntryName, lpRasEntry[dw].szEntryName );

szError.Format( _T("found entry: %s\r\n "),lpRasEntry[dw].szEntryName );
msg += szError;
}
}
}

if (!bRasEntryFound) return;
//// connection name
//wcscpy(rasDialParam.szEntryName, _T("T-Mobile Internet") );
//
// parameters from connection structure
dwRes = RasGetEntryDialParams(NULL, &rasDialParam, &bPasswd);

if(dwRes != 0)
{
szResult.Format( _T("getting Dial Params error: %D \r\n") , dwRes );
szResult += szError;
}
else
{
szResult.Format(L"entryname: %s, number: %s \r\n", rasDialParam.szEntryName,rasDialParam.szPhoneNumber);
msg += szResult;

}

//	szError.Format( _T("creat new Dial Params...\r\n"));
//msg += szError;
//	// Copy in the user credetials.
//_tcscpy( rasDialParam.szEntryName, _T("T-Mobile Internet") );
//_tcscpy( rasDialParam.szUserName, _T("t-mobile") );
//_tcscpy( rasDialParam.szPassword, _T("pwd") );
//_tcscpy( rasDialParam.szPhoneNumber, _T("*99#") );
//_tcscpy( rasDialParam.szCallbackNumber, _T("") );

szResult.Format(L"entryname: %s, number: %s \r\n", rasDialParam.szEntryName,rasDialParam.szPhoneNumber);
msg += szResult;
m_editbox.SetWindowTextW(msg);

do{
// if connection fails, hangup and retry... for 5 attemps

DWORD dwResult = RasDial(NULL,NULL,&rasDialParam,0,NULL,&g_rasConn);
Sleep(2000);
if ( dwResult != 0)
{
szError.Format(L"RAS error: %d \r\n", dwResult);
msg += szError;
m_editbox.SetWindowTextW(msg);
RasHangUp(g_rasConn);
g_rasConn = NULL;
n_attempts--;
}
else {
break;
}
}
while(n_attempts);

if(n_attempts == 0)
{
//AddDebugInfo( L"Can't connect GPRS" );
}
else
{
RASCONNSTATUS rasConStatus;
memset(&rasConStatus, 0, sizeof(RASCONNSTATUS));
rasConStatus.dwSize = sizeof(RASCONNSTATUS);

RasGetConnectStatus(g_rasConn, &rasConStatus);

if(rasConStatus.dwError == 0) {
szResult.Format( L"GPRS connected \r\n" );
msg += szResult;
}
else
{
szResult.Format(L"Ras connect status: %s \r\n", rasConStatus.dwError);
msg += szResult;
}
}

m_editbox.SetWindowTextW(msg);
return;
}