#include <windows.h>
#include<Wininet.h>
#pragma comment(lib, "Wininet.lib")
BOOL Download(const TCHAR *Url, const TCHAR *wzFile)
{
BOOL bRet = FALSE;
HINTERNET hInternet = InternetOpen(TEXT("RookIE/1.0"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if(hInternet != NULL)
{
HINTERNET hUrl = InternetOpenUrl(hInternet, Url, NULL, 0, INTERNET_FLAG_DONT_CACHE, 0);
if(hUrl != NULL)
{
DWORD dwSize = 0;
BYTE Buf[MAX_PATH] = {0};
FILE *fp = _tfopen(wzFile, TEXT("wb"));
if(fp != NULL)
{
do
{
InternetReadFile(hUrl, Buf, MAX_PATH - 1, &dwSize);
fwrite(Buf, sizeof(BYTE), dwSize , fp);
}while(dwSize>0);
fclose( fp );
bRet = TRUE;
}
InternetCloseHandle(hUrl);
hUrl = NULL;
}
}
InternetCloseHandle(hInternet);
hInternet = NULL;
return bRet;
}