CInternetSession::OpenURL
C / C++ / MFC
2
Posts
2
Posters
0
Views
1
Watching
-
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
-
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
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