Discussion:
URLDownloadToFile Error -2147024891
(too old to reply)
Chamitha
2005-04-14 21:19:34 UTC
Permalink
The URLDownloadToFile API returns the status code -2147024891 when
attempting to download from a valid HTTP or FTP location. If the URL is
pasted into the browser the file is downloaded thus verifying the
correctness and accessability of the URL. Any idea of the cause of this
behavious?
Igor Tandetnik
2005-04-14 21:29:01 UTC
Permalink
Post by Chamitha
The URLDownloadToFile API returns the status code -2147024891 when
attempting to download from a valid HTTP or FTP location. If the URL
is pasted into the browser the file is downloaded thus verifying the
correctness and accessability of the URL. Any idea of the cause of
this behavious?
The error is E_ACCESSDENIED. Are you, by any chance, calling
URLDownloadToFile from a service running under SYSTEM account?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Chamitha
2005-04-14 22:11:22 UTC
Permalink
No. Its is being called in a simple VB 6.0 EXE.
Chamitha
2005-04-14 22:15:41 UTC
Permalink
Sample

Dim RetCode As Long

RetCode = URLDownloadToFile(0,
"ftp://username:***@ftp.ftpurl.com/File.txt", "C:\Test\File.txt",
0, 0)

If Not (RetCode = 0) Then
MsgBox "Boom" 'The message box is displayed. RetCode = -2147024891
End If
Igor Tandetnik
2005-04-14 22:56:49 UTC
Permalink
Post by Chamitha
Sample
Dim RetCode As Long
RetCode = URLDownloadToFile(0,
0, 0)
Do you have rights to write to this file? In Explorer, can you create a
file in this directory?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Chamitha
2005-04-15 13:57:43 UTC
Permalink
Yes.
Chamitha
2005-04-15 20:08:55 UTC
Permalink
This issue only occurs on some PC's. Others work fine. Is there any
Service Pack or Patch which causes or elimiates this?
Chamitha
2005-04-17 22:18:33 UTC
Permalink
Seems like the issue has something to do with a proxy.
URLDownloadToFile API executed on the same PC when connect to the
internet via a authenticated proxy server fails, but succeeds when
connected directly.
Any idea if the API can be used with a proxy server? If so are any
modifications required?
Igor Tandetnik
2005-04-18 15:13:32 UTC
Permalink
Post by Chamitha
Seems like the issue has something to do with a proxy.
URLDownloadToFile API executed on the same PC when connect to the
internet via a authenticated proxy server fails, but succeeds when
connected directly.
Any idea if the API can be used with a proxy server? If so are any
modifications required?
You should be able to create a COM object that implements
IBindStatusCallback and IAuthenticate, and pass it as the last
parameter. You can then supply user name and password via
IAuthenticate::Authenticate.

Another thing to try is InternetSetOption(NULL,
INTERNET_OPTION_PROXY_USERNAME) and INTERNET_OPTION_PROXY_PASSWORD. I'm
not sure if this works.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Viney Kumar
2010-01-07 22:53:11 UTC
Permalink
Igor Tandetnik,

I am also getting error from UrlDownloadToFile(). But, my scenario and error
code are different. It fails when executed from behind proxy and under
SYSTEM account. It works fine if I either use direct connection or run under
a user account. I am making following call:

URLDownloadToFile(NULL, wszURL, wszFullpath, 0, NULL);

I have a service that runs under SYSTEM credentials. This service launches a
program, say, DownloadMyFile.exe that downloads a file using above call.
This download works.

Then I connect my machine to proxy and specify the proxy thru IE options.
After this URLDownloadToFile starts giving INET_E_RESOURCE_NOT_FOUND
(-2146697211) error.

Now when I double click on DownloadMyFile.exe, which makes it run under user
credentials, it successfully works, even from behind proxy.

I tried this on Vista/Win7/XP and found same behavior.

Any clues?

url:http://www.ureader.com/msg/151615.aspx
Igor Tandetnik
2010-01-07 23:11:13 UTC
Permalink
Post by Viney Kumar
I am also getting error from UrlDownloadToFile(). But, my scenario
and error code are different. It fails when executed from behind
proxy and under
SYSTEM account. It works fine if I either use direct connection or
run under
URLDownloadToFile(NULL, wszURL, wszFullpath, 0, NULL);
I have a service that runs under SYSTEM credentials. This service
launches a program, say, DownloadMyFile.exe that downloads a file
using above call.
This download works.
Then I connect my machine to proxy and specify the proxy thru IE
options.
You do this while IE is running under which account? My guess is, IE settings are per user so SYSTEM never sees your settings and doesn't know it's supposed to use a proxy.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
Continue reading on narkive:
Search results for 'URLDownloadToFile Error -2147024891' (Questions and Answers)
4
replies
How do you make a program access the internet?
started 2011-01-10 13:30:09 UTC
programming & design
Loading...