Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to open url as a file

Status
Not open for further replies.

hennep

Programmer
Dec 10, 2000
429
I often use notepad to open an url. For instance when a page is redirected and I want to see the html code.
When you type an url in the file open dialog the operating system will do all the neccesary things to open and read the file.
Today I tried to do the same thing in one of my programs but with no result. I tried the open, fopen, FileOpen and OpenFile api's/functions and all of these failed.
I would like to open a file directly from the url without building the whole ftp client.

Does anybody know how to get this to work?
 
I'm not sure if this is what you are looking for or not but have you looked at CreateProcess or ShellExecuteEx?

James P. Cottingham
-----------------------------------------
I'm number 1,229!
I'm number 1,229!
 
When I use ShellExecute it depends on the association which program is used to handle the file.

What I want is opening a file in my own app.
like:

FILE *fp;
fp = fopen( "ftp://ftp.server.com", "r" );

the fopen function returns a NULL pointer when opening an url, I want to know which function is used by notepad when it opens an url.
 
When you "open" a remote URL in Notepad, it calls Internet Explorer which downloads the file into your "Temporary Internet Files" folder, and it is that file which is opened. If you click File -> Save As, you'll see that this is the case.

Now, since it is clear that Internet Explorer can be used to do non-interactive downloads, you would imagine that there would be a documented command-line option to do just that, but I can't find any. You probably need to use a COM interface. Typical Microsoft.

The alternatives would include:
(1) A command-line FTP/HTTP client, such as wget (see ). You would run the program then open the resulting file.
(2) The NMFTP or NMHTTP components which are bundled with C++Builder.
 
Thanks Tony,

I was hoping that one of the windows open functions would act as a wrapper and take care of the communication with IE.

I could also use the ftp.exe which is supplied with every windows version so far. But I prefer not to use any external programs.
After my first post I have found the Indy components at these contain an ftp client that can possibly do what I want. I give that a try first.
Haven't seen the NMFTP component yet, may be I should have a look before anything else. As you can read above, I haven't really made up my mind yet :)

thanks again,
Hennie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top