Solved

CInternetSession::OpenURL

Posted on 1997-12-22
1
485 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
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 100 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

789 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