PDA

Click to See Complete Forum and Search --> : URLDownloadToFile


SteveCRM
Jan 9th, 2002, 04:35 PM
Every time I use URLDownloadToFile my program freezes until the transfer is done...I want it to just download, and let the user still do things...

and one other thiing, using URLDownloadToFile how can I get the percent finished?

Thanks

Zaei
Jan 9th, 2002, 04:37 PM
You could probably thread URLDownloadToFile(). The last parameter of that function is a function pointer that you can specify download status.

Z.

SteveCRM
Jan 9th, 2002, 05:19 PM
good idea....thanks :D

Im not sure how to use that last parameter though :(

Zaei
Jan 9th, 2002, 06:02 PM
I looked at that post, and realized that the second part made no sense =).

Also, its not a function pointer, as I first thought. Its an Object, that inherits from IBindStatusCallback. Simply implement the OnProgress member function. There is lots of info in the MSDN.

Z.

Chris
Jan 10th, 2002, 02:01 AM
How about using API...


HINTERNET hInet=NULL;
HANDLE hFile=NULL;
DWORD dwByteDownload=0;
char Buff[10240];

// Open a new instance of the Internet Access
hInet = InternetOpen("MyXML", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (hInet != NULL)
{
// Access the given URL
hFile = InternetOpenUrl(hInet, "http://www.yahoo.com", NULL, 0, INTERNET_FLAG_RELOAD, 0);
if (hFile != NULL)
{
memset(Buff, '\0', 10240);
InternetReadFile(hFile, &Buff, Sz, &dwByteDownload);
}
}

// Close all the used handle
InternetCloseHandle(hInet);
InternetCloseHandle(hFile);


regards,