Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CInternetSession.OpenURL on Windows Mobile fails

CInternetSession.OpenURL on Windows Mobile fails

Scheduled Pinned Locked Moved C / C++ / MFC
c++htmldatabasecomsysadmin
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jessn
    wrote on last edited by
    #1

    Hi there I am trying to establish an Internet session (HTTP GET) with a MFC application on a Windows Mobile 6 platform. First I tried with OpenRequest() and SendRequest(), but when the code reached SendRequest () the application crashed in the evil way. Secondily I tried to use OpenURL() but it keeps saying that it cannot find the server. I have even connected the device to my WLAN to ensure I had a stable Internet connection.

    CString GoogleMap::getMapUrl(int width, int height, double lng, double
    lat, int zoom, CString format)
    {
    char * szUrl = (char*)malloc(256);
    char * szFormat = "http://maps.google.com/staticmap?center=%f,%f&format=%s&zoom=%d&size=%dx%d&key=%s";

    sprintf(szUrl, szFormat, lat, lng, format, zoom, width, height,m_szAPIKey);
    CString s = CString(szUrl);
    return s;
    }

    BYTE* GoogleMap::loadHttpFile(CString url, long &length)
    {
    BYTE* buffer = NULL;
    CInternetSession session;
    CHttpConnection * hc = NULL;

    hc = session.GetHttpConnection(_T("maps.google.com"), 0, 80, NULL,NULL);
    if (!hc) return NULL;
    //CHttpFile* pFile = hc->OpenRequest(CHttpConnection::HTTP_VERB_GET,_T("index.html"));
    //pFile->SendRequest();
    CHttpFile* pFile = (CHttpFile*)session.OpenURL(url); // FAILS!!!

    length = (long)pFile->GetLength();
    if (!length) return NULL;
    buffer = (BYTE*)malloc(length + 1);
    memset(buffer, 0, length +1);
    for ( DWORD dwRead1;dwRead1=pFile->Read(buffer,length); );
    return buffer;
    }

    Could someone please tell me what I do wrong? Thanks in advance, Jess -- Jess Nielsen, b.sc. Security Analyst http://jessn.blogspot.com/

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups