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

CInternetSession::OpenURL

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 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.
  • O Offline
    O Offline
    Ola Carlsson
    wrote on last edited by
    #1

    How can I use OpenURL and set max retries, timeout etc… If I use OpenURL and my connection doesn’t exist, the program crash. Thanks Ola Carlsson

    R 1 Reply Last reply
    0
    • O Ola Carlsson

      How can I use OpenURL and set max retries, timeout etc… If I use OpenURL and my connection doesn’t exist, the program crash. Thanks Ola Carlsson

      R Offline
      R Offline
      RobJones
      wrote on last edited by
      #2

      Hello, I use this bit of code to pull the text(source) from a provided url.. Maybe you can see something different with this code vrs yours.

      CString CUserProfileDlg::GetFile(const char *url, const char *filename)
      {
      char httpbuff[HTTPBUFLEN];
      TCHAR szCause[2048];
      CString Cause;
      Cause.Format("YES");

       TRY
       {
            CInternetSession mysession;
            CStdioFile \*remotefile = mysession.OpenURL(url,1,INTERNET\_FLAG\_TRANSFER\_BINARY|INTERNET\_FLAG\_RELOAD);
      
            CFile myfile(filename, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
            int numbytes;
      
            while (numbytes = remotefile->Read(httpbuff, HTTPBUFLEN))
      	  {
                 myfile.Write(httpbuff, numbytes);
      	  }
       }
      
       CATCH\_ALL(error)
       {
            error->GetErrorMessage(szCause,2046,NULL);
            Cause.Format("%s",szCause);
       }
       END\_CATCH\_ALL;
      
       return (Cause);
      

      }

      Rob

      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