thanks for all your help
after some playing around with URLDownloadToFile function, i discovered something about it.
if you use URLDownloadToFile in the main user interface thread, it will definately work.
if you use URLDownloadToFile in a worker thread, it may or may not work depending on your OS and your internet explorer. I am not sure which version is usable, but if your code is version dependable, its best to use another style.
here's the code by someone else that i would recommend.
Code:
CString yahoo_url= "yahoo.com"
CString Data;
DeleteUrlCacheEntry(yahoo_url);// delete the old stupid cache
HINTERNET IntOpen = ::InternetOpen("Sample", LOCAL_INTERNET_ACCESS, NULL, 0, 0);
HINTERNET handle = ::InternetOpenUrl(IntOpen, yahoo_url, NULL, NULL, NULL, NULL);
//HANDLE hFile = ::CreateFile("c:\\index.txt", GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
char Buffer[1024];
DWORD dwRead =0;
while(::InternetReadFile(handle, Buffer, sizeof(Buffer), &dwRead) == TRUE)
{
if ( dwRead == 0)
break;
DWORD dwWrite = 0;
// ::WriteFile(hFile, Buffer, dwRead, &dwWrite, NULL);
Data+=Buffer;
}
//::CloseHandle(hFile);
::InternetCloseHandle(handle);
in order to delete cache you need the following at the top
Code:
#include "wininet.h" // for clearing URL cache DeleteUrlCacheEntry
#pragma comment(lib, "wininet.lib") // for clearing URL cache DeleteUrlCacheEntry
the reason why you should delete cache is because you would want the newest version of the page and IE would not download the newest version if it has it cached
please give me a rating if this has helped you!