URLDownloadToFile function returns INET_E_DOWNLOAD_FAILURE on Windows XP

1

I've compiled a Win32 console app in C++ that at some point attempts to download a file from a URL. Built on Visual Studio 2019 and Windows 10, it targets a Windows XP 2002 SP3 system (compiled using the Visual Studio 2015 - Windows XP v140xp Platform Toolset). The app installs and runs fine on the target system, except for the issue I am about to describe.

When the program tries to download a file calling URLDownloadToFile function like so:

std::wstring stemp;
    std::wstring stemp2;
    LPCWSTR lpcURL;
    stemp = s2ws(url);
    lpcURL = stemp.c_str();
    LPCWSTR lpcURL2 = lpcURL;

    //Convert the string to a LPCSTR type so we can use it in the URLDownloadToFile() function
    LPCWSTR lpcDestination;
    stemp2 = s2ws(destination);
    lpcDestination = stemp2.c_str();


    CoInitialize(NULL);

    HRESULT hr = URLDownloadToFile(NULL, lpcURL, lpcDestination, 0, NULL);


    return hr;

The function fails and returns INET_E_DOWNLOAD_FAILURE consistently. The call to URLDownloadToFile actually translates to URLDownloadToFileW since I am using Unicode. However, I have also tried using URLDownloadToFileA for targeting the XP system (although I believe Unicode is supported on XP).

The call to CoInitialize(NULL) was added because of a post I read somewhere to try to remedy this, but my original code (running fine on Win 10) does not include it and runs fine without it.

I also ran the App on Win 10 using XP compatibility mode and it works fine.

But when I get to the target system (Win XP) this URLDownloadToFile function keeps failing with INET_E_DOWNLOAD_FAILURE.

The URL is less than 130 characters long, as per: URLDownloadToFile fails with 0x800c0008 (INET_E_DOWNLOAD_FAILURE) depending on length of URL Something along the lines of: https://storage.googleapis.com/account/platform/users/usernum/units/spec-file.xml which has public download access, and as I already said, can be seen and downloaded fine using the Win10 environment, which I have checked and re-checked for spelling errors.

There are no known firewalls, or antivirus programs blocking the access, as the same URL resource can be downloaded using Mozilla Firefox on the same XP machine. The program is running on an Admin account with full privileges. The only real difference is then the operating system.

And I am not getting using IBindStatusCallback as in: URLDownloadToFile fails with code 0x800c0008 (INET_E_DOWNLOAD_FAILURE)

Anybody have any tips or clues on how why this is happening and how to solve this for Win XP?

Thanks!

c++
winapi
windows-xp
asked on Stack Overflow Jun 5, 2020 by DaveAl

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0