locked
Problem in establishing GPRS connection through Connection Manager API RRS feed

  • Question

  • Hello,
    I'm developing win32 application for windows mobile 6 which establish a GPRS connection for accessing internet resources.Code what i'm using for establishing GPRS connection is given below :

    HRESULT hr = S_OK;   
    DWORD dwIndex, dwStatus, dwErrorCode ;
    CONNMGR_CONNECTIONINFO ci = {0};
      
    dwIndex = dwStatus = dwErrorCode = 0;

    // Register with the connection manager
     ci.cbSize = sizeof(CONNMGR_CONNECTIONINFO);
     ci.dwParams = CONNMGR_PARAM_GUIDDESTNET;
      ci.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
     ci.guidDestNet = IID_DestNetInternet ;
     
     hr = ConnMgrEstablishConnectionSync(&ci, &hConnection, 30*1000, &dwStatus);

      /*checking the connection status*/

       //initializing application's use of the WinInet functions.
       hInternet = InternetOpen(TEXT("Mitr-App"), INTERNET_OPEN_TYPE_DIRECT, abs_null, abs_null, 0);
       if (hInternet == abs_null){
            dwErrorCode = GetLastError();
            return FALSE;               
        }
    /* using the connection through wininet api*/

    // releasing the connection
    ConnMgrReleaseConnection(hConnection, TRUE);

    The behaviour of this code is totally unpredictable few times it works fine and most of the times it fails.In case of fail scenario it returns the status code is CONNMGR_STATUS_CONNECTIONFAILED ie The connection failed and cannot be reestablished.
    At the same time i'm using Pocket IE for brwosing internet it successfully establish the connection and access the network while i cann't.
    Please help me whats worng in this code.
    Can anyone tell me what is robust method for accessing internet through GPRS in windows mobile becoz whenever i'm googling i endup on connection manager api.
    If i run PIE first then my app then it works perfectly fine but when i run my app first its not able to establish the connection.

    Friday, February 20, 2009 5:13 AM

All replies

  • Hi,

    Refer this http://blogs.msdn.com/windowsmobile/archive/2005/09/14/466579.aspx

    Azad.S Please remember to mark the replies as answers if they help and unmark them if they provide no help
    • Proposed as answer by azad123321 Friday, February 20, 2009 8:52 AM
    Friday, February 20, 2009 8:52 AM
  • Hello ,
    thanks for quick response.
    if u check it closely my code is almost same as in the link provided by you except few things which is intentionally like i don't want use proxy configuration in establishing network request thats why i'm using INTERNET_OPEN_TYPE_DIRECT access type in InternetOpen api.Due to this reason i'm not calling ConnMgrProviderMessage api for getting proxy information.Also i'm not using ConnMgrMapURL api for mapping url to GUID of internet coz i'm permanently want to connect to internet.
    One more question i want to ask is what Pocket Internet Explorer do diffenrent for establishing network connection and i'm not doing that .

    Thanks in advance ..
    please help me.


    Friday, February 20, 2009 10:56 AM