Solved

CInternetSession::OpenURL

Posted on 1997-06-01
6
719 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
lucky13 challenge 11 120
matchUp  challenge 6 52
ASP.NET C# MessageBox.Show Showing a modal dialog box or form when the application ... 2 102
Change to event 1 100
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

15 Experts available now in Live!

Get 1:1 Help Now