Показать сообщение отдельно

  #15  
Старый 06.07.2007, 18:59
NetMan
Участник форума
Регистрация: 09.02.2004
Сообщений: 122
С нами: 11710201

Репутация: 134
По умолчанию

Sorry 2 all...
Вот накатал скачивание при помощи класса CInternetFile библиотеки MFC.
Код:
void DownloadFile(LPCSTR pstrURL,LPCSTR lpszFileName)
{
	CInternetSession inetSession;
	CInternetFile *inetFile = (CInternetFile *) inetSession.OpenURL(pstrURL, 1, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_DONT_CACHE);
	CFile file(lpszFileName,CFile::modeCreate | CFile::modeWrite | CFile::typeBinary); 

	char buf[8192];
	DWORD dwBytesRead;
	while (dwBytesRead=inetFile->Read(buf, sizeof(buf)))
		file.Write(buf, dwBytesRead);
	
	inetFile->Close();
	delete inetFile;
	inetSession.Close();
}