?
Solved

CInternetSession::OpenURL

Posted on 1997-12-22
1
Medium Priority
?
495 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

762 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