Thread: URLDownloadToFile<A/W>() does nothing

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    104

    URLDownloadToFile<A/W>() does nothing

    Hello,

    I finally found the solution to how to link my gcc compiler to the urlmon library and to its respective header.

    The thing is, when I call the function, it is as if it does nothing.
    No file is downloaded to my PC, and, I call GetLastError() and it returns 0 .

    I don't know if I am calling it correctly but, here is how I call it:
    Code:
    URLDownloadToFileW(NULL, "www.myurlhere.com/myfilehere.fileextension", "filename.fileextension", 0, NULL)
    Here are my assumptions as to why this problem is occuring:

    1. It might be because the header or library I found are corrupted; but, the compiler does not complain about this.

    2. I am not passing the parameters of the function correctly. I assume this since the compiler complains that I am passing args 2 and 3 from incompatible pointer types.

    Any help is greatly appreciated.
    Last edited by abraham2119; 05-03-2009 at 08:00 PM.

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    1. It might be because the header or library I found are corrupted; but, the compiler does not complain about this.
    This is where my internal voice says "You've got bigger problems..."

    2. I am not passing the parameters of the function correctly. I assume this since the compiler complains that I am passing args 2 and 3 from incompatible pointer types.
    And your compiler is right. It's a W function, meaning it takes UTF-16 strings. Along the lines of:
    Code:
    URLDownloadToFileW(NULL, L"www.myurlhere.com/myfilehere.fileextension", L"filename.fileextension", 0, NULL)
    Or, use the Unicode macros windows provides:
    Code:
    URLDownloadToFile(NULL, TEXT("www.myurlhere.com/myfilehere.fileextension"), TEXT("filename.fileextension"), 0, NULL)
    ...which will expand to either the A or W variant, depending on if UNICODE is #define'd.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Registered User
    Join Date
    Dec 2008
    Posts
    104
    I call the function as:
    Code:
    URLDownloadToFileW(NULL, L"www.myurlhere.com/myfilehere.fileextension", L"filename.fileextension", 0, NULL)
    and nothing occurs.

    I call GetLastError() and it returns 0. The function does not return S_OK nor E_OUTOFMEMORY.

    What is wrong?

Popular pages Recent additions subscribe to a feed