[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

CInternetSession::OpenURL

Posted on 1997-12-22
1
Medium Priority
?
498 Views
Last Modified: 2013-11-19
The following is a function meant to load a webpage into the buffer.  It works fine except if url is not a valid url, or even if it just times out OpenURL does not return.  Instead an exception is thrown in kernel32.dll.  This isn't acceptable behavoir for my app.  However the function works perfectly if it find a valid url.  Does anybody have any ideas?  Any thoughts would be greatly appreciated. Thanx!

CInternetSession is("SPIDER");

int LoadURL(const char* url,char* buffer,int bufferSize)
{
 CStdioFile *urlHandle;
 char tmpBuffer[1000];
 int lenIntoBuf = 0;

 urlHandle = is.OpenURL(url);

 if (urlHandle == NULL)
  return 0;

 while (urlHandle->ReadString(tmpBuffer,1000) && 
  lenIntoBuf < bufferSize)
 {
 strncpy(buffer+lenIntoBuf,tmpBuffer,bufferSize-lenIntoBuf);
 lenIntoBuf += strlen(tmpBuffer);
 }
 return lenIntoBuf;
}
0
Comment
Question by:tlsoftware
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 200 total points
ID: 1312908
OpenUrl is supposed to throw CInternetException. You should use try-catch.

try
{
    urlHandle = is.OpenURL(url);
}
catch (CInternetException *e)
{
    // exception handler
    // ...

    e->Delete();
}

0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question