Solved

CInternetSession::OpenURL

Posted on 1997-06-01
6
714 Views
Last Modified: 2013-11-20
I'm having problems with the CInternetSession::OpenURL() WinInet class function.

It works just fine for a "file:" URL, but returns an empty CStdioFile object for "http:" or "ftp:" URL's.

What am I doing wrong?  Do I need to create some sort of connection before using OpenURL on an http or ftp object?

Thanx!
0
Comment
Question by:TM-Faust
  • 3
  • 2
6 Comments
 

Author Comment

by:TM-Faust
ID: 1301909
Let me elaborate on what I'm trying to do:

I need to download a text file that a UNIX program I wrote generated.  If I download this file to my computer, and load it into my MFC application as a "file:" URL, it works fine, but i can't pull it down from the web server as a "http:" URL.
0
 

Accepted Solution

by:
schlegel earned 100 total points
ID: 1301910
I have a program that does something very similar. I first create a
CInternetSession object using the following constructor parameters:

CInternetSession(sAgent,1,PRE_CONFIG_INTERNET_ACCESS,NULL,NULL,0)

sAgent referring to the app name.  I then call OpenURL() with the complete "http://" address.  I fill in a CHttpFile pointer with the returned pointer.  That is the way I do it and it works for me.
0
 

Author Comment

by:TM-Faust
ID: 1301911
I followed your suggestion schlegel, and it still doesn't work.

Here's what I have:

CInternetSession internet(NULL,1,PRE_CONFIG_INTERNET_ACCESS,NULL,NULL,0);

m_server_file = internet.OpenURL(m_server_edit);

where m_server_file is of type CStdioFile* and m_server_edit is a CString containing the correctly formatted "http://" string.

after the call to OpenURL, here's what VC++ debugger has in m_server_file:

m_server_file      0x00761230 {FILE*=0x00000000 name=???}

and m_server_file->m_pStream = NULL

ideas?

remember, this works fine if m_server_edit is of type "file:///"


0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Expert Comment

by:schlegel
ID: 1301912
I think I ran into problems when I didn't provide the constructors first parameter (the app's name).  Try filling it in.  I know what the docs say about NULL but I think I had to fill in the agent string.
0
 

Author Comment

by:TM-Faust
ID: 1301913
great!!  that seems to have done it!  thanx!!
0
 

Expert Comment

by:bsturk
ID: 1301914
I'd like to know how to save the contents of that file pointer, namely the CStdioFile*.  How can you save it to disk?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now