急::网络中,已知文件的URL,如何将它下载到我的本地机的某个确定目录中去。。。 URLDownloadToFile(NULL, "http://www.csdn.net/", "c:\\temp\\file.html", 0, NULL); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 bool SaveUrl(LPCTSTR url, LPCTSTR filename){ HINTERNET hNet = ::InternetOpen("Outlook", PRE_CONFIG_INTERNET_ACCESS, NULL, INTERNET_INVALID_PORT_NUMBER, 0) ; HINTERNET hUrlFile = ::InternetOpenUrl(hNet, url, NULL, 0, INTERNET_FLAG_RELOAD, 0) ; char buffer[10*1024] ; DWORD dwBytesRead = 1; BOOL bRead=TRUE; CFile file; file.Open(filename,CFile::modeCreate|CFile::modeWrite); while(bRead&&dwBytesRead>0) { bRead = ::InternetReadFile(hUrlFile, buffer, sizeof(buffer), &dwBytesRead); if(dwBytesRead>0) file.Write(buffer,dwBytesRead); } ::InternetCloseHandle(hUrlFile) ; ::InternetCloseHandle(hNet) ; file.Close(); AfxMessageBox("finished"); return bRead;}void CC02021101Dlg::OnOK(){ // TODO: Add extra validation here bool bret=SaveUrl("http://club.pchome.net/bbs2.php?topic=40&lanmuid=2","C:\\temp\\test.html"); if(bret) AfxMessageBox("true"); else AfxMessageBox("false");} HINTERNET' : undeclared identifier ??要加什么头文件么?? Wininet.h Wininet.lib 有谁知道,哪儿有例子代码??MY EMAIL: [email protected] 使用了 masterz 的代码,编译通过。运行后,很快就跳出“finished”;而且:下载zip文件时,得到的*.zip文件很小,只有1.05K; 下载html文件时,得到的*.html文件打开是无效的网页;谁可以指导我一下,谢谢!! 使用了 masterz 的代码,编译通过。运行后,很快就跳出“finished”;而且:下载zip文件时,得到的*.zip文件很小,只有1.05K; 下载html文件时,得到的*.html文件打开是无效的网页;谁可以指导我一下,谢谢!! 在DirectX窗口中添加Activex控件 文件读写的问题 文件传输厚CFILE写入的问题 求助:自己制作播放器问题(ActiveX) 关于CListView绘制背景图片的问题 数据库问题. 如何实现程序备份正在使用的系统文件? 求助,为何我的程序编译为release版本后仍然输出DebugArchive文件?? 迎五一,散分! 在mscomm控件里,怎么把发送缓冲区的内容放到数组里 如何把我的程序做成可以安装到别的机子上的软件? 请问一个基本问题:怎样知道复选框是打了钩还是没打钩??(用API)
{
HINTERNET hNet = ::InternetOpen("Outlook",
PRE_CONFIG_INTERNET_ACCESS,
NULL,
INTERNET_INVALID_PORT_NUMBER,
0) ; HINTERNET hUrlFile = ::InternetOpenUrl(hNet,
url,
NULL,
0,
INTERNET_FLAG_RELOAD,
0) ; char buffer[10*1024] ;
DWORD dwBytesRead = 1;
BOOL bRead=TRUE;
CFile file;
file.Open(filename,CFile::modeCreate|CFile::modeWrite);
while(bRead&&dwBytesRead>0)
{
bRead = ::InternetReadFile(hUrlFile,
buffer,
sizeof(buffer),
&dwBytesRead);
if(dwBytesRead>0)
file.Write(buffer,dwBytesRead);
}
::InternetCloseHandle(hUrlFile) ;
::InternetCloseHandle(hNet) ;
file.Close();
AfxMessageBox("finished");
return bRead;
}
void CC02021101Dlg::OnOK()
{
// TODO: Add extra validation here
bool bret=SaveUrl("http://club.pchome.net/bbs2.php?topic=40&lanmuid=2","C:\\temp\\test.html");
if(bret)
AfxMessageBox("true");
else
AfxMessageBox("false");
}
要加什么头文件么??
MY EMAIL: [email protected]
下载zip文件时,得到的*.zip文件很小,只有1.05K;
下载html文件时,得到的*.html文件打开是无效的网页;谁可以指导我一下,谢谢!!
下载zip文件时,得到的*.zip文件很小,只有1.05K;
下载html文件时,得到的*.html文件打开是无效的网页;谁可以指导我一下,谢谢!!