URLDownloadToFile() not allowing the program to return value
Hello guys.
I am new here, hope we will have good time together.
I've been writing some code and this is part of it:
Code:
...
URLDownloadToFile(NULL, _T("http://something/something.txt"), path, 0, NULL);
return 0;
}
The file gets downloaded successfully but the downloader wont exit (return value 0). So it remains active.
I am sure the problem is URLDownloadToFile()
Anyone have idea what's going on?
I am using Visual Studio 2010 Express.
Thanks for your time.
Re: URLDownloadToFile() not allowing the program to return value
Quote:
Originally Posted by
darkyzzw0w
I am sure the problem is URLDownloadToFile()
Where is your check of the return code of URLDownloadToFile? What does that function return?
Regards,
Paul McKenzie
Re: URLDownloadToFile() not allowing the program to return value
When I remove that line, the program exists successfully, and with it, it wont end.
Re: URLDownloadToFile() not allowing the program to return value
Quote:
Originally Posted by
darkyzzw0w
When I remove that line, the program exists successfully, and with it, it wont end.
How long did you wait for the URLDownloadToFile return?
How did you know that "file gets downloaded successfully"?
Re: URLDownloadToFile() not allowing the program to return value
Quote:
Originally Posted by
darkyzzw0w
When I remove that line, the program exists successfully, and with it, it wont end.
That is not what I asked.
What is the return code from URLDownLoadToFile?
When you call an API function that is documented to return a value back to you, you're code should be checking the return code. Just assuming that functions "work" without checking return codes is not the way to use an API properly.
Regards,
Paul McKenzie
Re: URLDownloadToFile() not allowing the program to return value
Quote:
Originally Posted by
darkyzzw0w
I am sure the problem is URLDownloadToFile()
And I'm sure it's not. :)
Code:
#include <windows.h>
#include <urlmon.h>
#include <stdio.h>
#pragma comment(lib, "urlmon.lib")
int main()
{
HRESULT hr = URLDownloadToFile (NULL, __argv[1], "foofoo.bin", 0, NULL);
printf("%s\n", SUCCEEDED(hr) ? "Success" : "Failed");
return 0;
}
Code:
E:\Temp\694>694.exe http://msdn.microsoft.com/en-us/library/ms775123%28v=vs.85%29.aspx
Success
foofoo.bin
Code:
<!DOCTYPE html>
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head><link rel="canonical" href="http://msdn.microsoft.com/en-us/library/ms775123(v=vs.85).aspx" />
<title>URLDownloadToFile function (Windows)</title>
<script type="text/javascript" src="http://i2.msdn.microsoft.com/Areas/Epx/Content/Scripts/modernizr2.custom.epx.js" data-do-not-move="true"> </script>
<meta name="DCS.dcsuri" content="/en-us/library/ms775123(d=default,l=en-us,v=vs.85).aspx" />
<meta name="NormalizedUrl" content="http://msdn.microsoft.com/en-us/library/ms775123(d=default,l=en-us,v=vs.85).aspx" />
<meta name="VotingContextUrl" content="http://msdn.microsoft.com/en-us/library/ms775123(d=default,l=en-us,v=vs.85).aspx" />
<meta name="MN" content="FB361393-2:51:11 AM" />
<meta name="Search.ShortId" content="ms775123" />
<meta name="Ms.Locale" content="en-us" />
. . .
Re: URLDownloadToFile() not allowing the program to return value
Quote:
Originally Posted by
darkyzzw0w
I've been writing some code and this is part of it:
Code:
...
URLDownloadToFile(NULL, _T("http://something/something.txt"), path, 0, NULL);
return 0;
}
The file gets downloaded successfully but the downloader wont exit (return value 0). So it remains active.
I am sure the problem is URLDownloadToFile()
How is path defined?
Please produce a full working test program that demonstrates the problem (like Igor posted) and post the program here.