Solved

CInternetSession::OpenURL

Posted on 1997-06-01
6
726 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 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