Board index » cppbuilder » ActionList, Internet, TDownLoadURL

ActionList, Internet, TDownLoadURL


2005-07-15 03:42:08 AM
cppbuilder60
TDownLoadURL *mydl;
mydl->URL = "www.mysite.com/afile.txt";
mydl->Filename = "afile.txt";
mydl->Execute();
If the file specified by mydl->URL does not exist, mydl->Execute() pops up
an error message dialog box informing the user that the file could not be
found. This dialog box is a major annoyance. If I want the user to be
informed of this, I will tell him about it myself.
Is there some way to check a webserver/website for the existance of a file
before attempting to download it? Or some way to get rid of that dialog box?
I'd love to take the call to the messagebox out, but I don't have the source
code for the Execute method of TDownLoadURL (or if I do, I can't find it).
I'm using C++Builder version 6.0. Is there some way I can get a copy of it?
Thanx for any help you can give me with this.
Pete
 
 

Re:ActionList, Internet, TDownLoadURL

"Pete" < XXXX@XXXXX.COM >wrote in message
Quote
Is there some way to check a webserver/website for
the existance of a file before attempting to download it?
Not with TDownloadURL, no.
Quote
Or some way to get rid of that dialog box?
Have you tried wrapping the Execute() in a try..catch block yet?
The alternative is not use TDownloadURL at all. TDownloadURL uses
URLDownloadToFile() from urlmon.dll. You could simply call the function
manually. Then you can react to any failure directly. Otherwise, find a
suitable HTTP component and use the HTTP protocol directly instead. You can
then respond to the HTTP responses as needed.
Gambit
 

Re:ActionList, Internet, TDownLoadURL

Thank you very much!
Yes, I had tried wrapping Execute() in a try..catch block. That gets rid of
the "exception occurred" messagebox, but not the "file not found" message
box.
The URLDownloadToFile() function seems to have done the job.
I have a couple of questions about URLDownloadToFile. In urlmon.h, it is
defined as follows:
#define URLDownloadToFile URLDownloadToFileA
STDAPI
URLDownloadToFileA(LPUNKNOWN,LPCSTR,LPCSTR,DWORD,LPBINDSTATUSCALLBACK);
1) can you tell me what the parameters specify? I used the following call:
char urloffiletodownload[] = www.mysite.com/afile.txt; //source
filename
char filetosavetodisk[] = "afile.txt"; //destination filename
URLDownloadToFile(NULL, urloffiletodownload, filetosavetodisk,0,NULL);
which seems to have worked, but can you tell me what the LPUNKNOWN, the
DWORD value, and the LPBINDSTATUSCALLBACK parameters are for?
2) it seem seems to return 0 (in the EAX register) regardless of whether it
finds the file or not (if not, it doesn't throw an exception). Is there some
way of checking for the success or failure of the function in performing the
download? ... other than checking for the existance of the
(filetosavetodisk) file.
Thank you again for your help.
Pete
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Pete" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>Is there some way to check a webserver/website for
>the existance of a file before attempting to download it?

Not with TDownloadURL, no.

>Or some way to get rid of that dialog box?

Have you tried wrapping the Execute() in a try..catch block yet?

The alternative is not use TDownloadURL at all. TDownloadURL uses
URLDownloadToFile() from urlmon.dll. You could simply call the function
manually. Then you can react to any failure directly. Otherwise, find a
suitable HTTP component and use the HTTP protocol directly instead. You
can
then respond to the HTTP responses as needed.


Gambit


 

{smallsort}

Re:ActionList, Internet, TDownLoadURL

"Pete" < XXXX@XXXXX.COM >wrote in message
Quote
Yes, I had tried wrapping Execute() in a try..catch block. That
gets rid of the "exception occurred" messagebox, but not the
"file not found" message box.
Further investigation shows that the exception is being thrown in the
context of TApplication::WndProc(), which calls
TApplication::HandleException() for any unhandled exception that is thrown.
If TApplication::OnException is not assigned a handler than ShowException()
is called to display a popup message.
The simple way to handle the exception directly is not call
TDownloadURL::Execute(). Assuming your TDownloadURL is a member of a form,
you can call the form's ExecuteAction() method instead, which will directly
call TDownloadURL::ExecuteTarget(), which calls URLDownloadToFile(). If
ExecuteTarget() throws an exception, placing a try..catch block around
ExecuteAction() will be able to detect and handle the exception as expected.
Quote
1) can you tell me what the parameters specify?
URLDownloadToFile Function
msdn.microsoft.com/workshop/networking/moniker/reference/functions/urldownloadtofile.asp
Quote
2) it seem seems to return 0 (in the EAX register) regardless of
whether it finds the file or not (if not, it doesn't throw an exception).
URLDownloadToFile() does not throw any exception. A return value of 0 means
the function succeeded.
Quote
Is there some way of checking for the success or failure of the
function in performing the download?
That is what the return value is for.
Gambit
 

Re:ActionList, Internet, TDownLoadURL

Thank you again. My problem is solved and all of my questions are answered.
Pete
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Pete" < XXXX@XXXXX.COM >wrote in message
news:42d6efad$ XXXX@XXXXX.COM ...

>Yes, I had tried wrapping Execute() in a try..catch block. That
>gets rid of the "exception occurred" messagebox, but not the
>"file not found" message box.

Further investigation shows that the exception is being thrown in the
context of TApplication::WndProc(), which calls
TApplication::HandleException() for any unhandled exception that is
thrown.
If TApplication::OnException is not assigned a handler than
ShowException()
is called to display a popup message.

The simple way to handle the exception directly is not call
TDownloadURL::Execute(). Assuming your TDownloadURL is a member of a
form,
you can call the form's ExecuteAction() method instead, which will
directly
call TDownloadURL::ExecuteTarget(), which calls URLDownloadToFile(). If
ExecuteTarget() throws an exception, placing a try..catch block around
ExecuteAction() will be able to detect and handle the exception as
expected.

>1) can you tell me what the parameters specify?

URLDownloadToFile Function

msdn.microsoft.com/workshop/networking/moniker/reference/functions/urldownloadtofile.asp

>2) it seem seems to return 0 (in the EAX register) regardless of
>whether it finds the file or not (if not, it doesn't throw an exception).

URLDownloadToFile() does not throw any exception. A return value of 0
means
the function succeeded.

>Is there some way of checking for the success or failure of the
>function in performing the download?

That is what the return value is for.


Gambit


 

Re:ActionList, Internet, TDownLoadURL

Hi,
I am facing the same challenge as Pete.
However, I tried the same function URLDownloadToFile() to download web pages but it works only for text.
I need to download the web page with its pictures (similar to
doing manually: File|Save As| and the select mht or "Web Page
html only" the third option"
Here is what I tried:
char urloffiletodownload[] = "www.ford.com/en/default.htm"; //source filename
char filetosavetodisk[] = "C:\\WebWithPics.html"; //destination filename
URLDownloadToFile(NULL, urloffiletodownload, filetosavetodisk,0,NULL);
Does anyone know how to do this?
thanks in advance
Rob
"Pete" < XXXX@XXXXX.COM >wrote:
Quote
Thank you again. My problem is solved and all of my questions are answered.
Pete

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
news:42d6fd7f$ XXXX@XXXXX.COM ...
>
>"Pete" < XXXX@XXXXX.COM >wrote in message
>news:42d6efad$ XXXX@XXXXX.COM ...
>
>>Yes, I had tried wrapping Execute() in a try..catch block. That
>>gets rid of the "exception occurred" messagebox, but not the
>>"file not found" message box.
>
>Further investigation shows that the exception is being thrown in the
>context of TApplication::WndProc(), which calls
>TApplication::HandleException() for any unhandled exception that is
>thrown.
>If TApplication::OnException is not assigned a handler than
>ShowException()
>is called to display a popup message.
>
>The simple way to handle the exception directly is not call
>TDownloadURL::Execute(). Assuming your TDownloadURL is a member of a
>form,
>you can call the form's ExecuteAction() method instead, which will
>directly
>call TDownloadURL::ExecuteTarget(), which calls URLDownloadToFile(). If
>ExecuteTarget() throws an exception, placing a try..catch block around
>ExecuteAction() will be able to detect and handle the exception as
>expected.
>
>>1) can you tell me what the parameters specify?
>
>URLDownloadToFile Function
>
>msdn.microsoft.com/workshop/networking/moniker/reference/functions/urldownloadtofile.asp
>
>>2) it seem seems to return 0 (in the EAX register) regardless of
>>whether it finds the file or not (if not, it doesn't throw an exception).
>
>URLDownloadToFile() does not throw any exception. A return value of 0
>means
>the function succeeded.
>
>>Is there some way of checking for the success or failure of the
>>function in performing the download?
>
>That is what the return value is for.
>
>
>Gambit
>
>


 

Re:ActionList, Internet, TDownLoadURL

"rob kemp" < XXXX@XXXXX.COM >wrote in message
Quote
I tried the same function URLDownloadToFile() to download
web pages but it works only for text.

I need to download the web page with its pictures (similar to
doing manually: File|Save As| and the select mht or "Web Page
html only" the third option"
URLDownloadToFile() does not support what you are asking for (nor does any
other library, AFAIK). You will have to download the starting HTML, then
parse it to retreive all of the URLs of the individual files that it uses,
then download all of them separately one at a time, and then finally create
the MHT file yourself from scratch.
Gambit