I have a very simple looking C++ code that uses URLDownloadToFile and fails when run 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.