Solved

CInternetSession::OpenURL

Posted on 1997-06-01
6
730 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 65
not able to insert into temp table 68 169
java ^ examples 8 69
canBalance challenge 34 96
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

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