Solved

CInternetSession::OpenURL

Posted on 1997-06-01
6
734 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
[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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to retreive data from .TFS file exported by DVR 8 244
repeatEnd java challenge 42 85
Pressing cancel button with C# UI Automation 3 92
notReplace  challenge 53 151
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

696 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