我要写一个下载程序,功能很简单,只访问服务器然后下载文件,请问该如何实现?最好有代码说明,谢谢先!!!
解决方案 »
- SendRequest域名解析失败被重定向
- 自己画控件,做拖拽功能,发现wm_lbuttonup不响应,求解~
- 问大家一个问题~~
- 请问CRecordSet类能无绑定的对事先不知道结构的数据库进行写操作吗?
- 怎样把系统自动弹出的MESSAGE BOX屏蔽掉,大家说说
- 挑战高手,有本事你就答出来!!
- 交友,关于VC编程的!!
- 想问一下关于绘图刷新的问题
- MFC中使用BROWSEINFO来选择文件夹的问题
- 为什么vs2013编译的程序,exe点击无反应,只有将源码重新编译生成才能打开
- 从msdn上面下载了一个例子,出现如下提示
- 在我的classview里面怎么没了我要用的一个类了 在线等待,马上给分
MSDN找wininet就可以了。
例子可以看看MSDN中的FTPTree
CHttpFile* pSzzsFile = (CHttpFile*)(sessionSzzs.OpenURL(_T("http://www.XXX.com/1.zip")));
if(pSzzsFile != NULL)
{
CFile szzsTargetFile;
BOOL bResult = szzsTargetFile.Open(_T("c:\\1.zip"),
CFile::modeCreate | CFile::modeWrite);
if(!bResult)
return FALSE;
while(bResult)
{
char* chBuff = new char[1025];
UINT nCount = pSzzsFile->Read(chBuff, 1024);
if(nCount > 0)
szzsTargetFile.Write(chBuff, nCount);
else
{
szzsTargetFile.Close();
pSzzsFile->Close();
delete pSzzsFile;
break ;
}
}
}
Compiling...
downloadDlg.cpp
E:\aa\download\downloadDlg.cpp(100) : error C2065: 'CInternetSession' : undeclared identifier
E:\aa\download\downloadDlg.cpp(100) : error C2146: syntax error : missing ';' before identifier 'sessionSzzs'
E:\aa\download\downloadDlg.cpp(100) : error C2065: 'sessionSzzs' : undeclared identifier
E:\aa\download\downloadDlg.cpp(101) : error C2065: 'CHttpFile' : undeclared identifier
E:\aa\download\downloadDlg.cpp(101) : error C2065: 'pSzzsFile' : undeclared identifier
E:\aa\download\downloadDlg.cpp(101) : error C2059: syntax error : ')'
E:\aa\download\downloadDlg.cpp(108) : error C2562: 'OnOK' : 'void' function returning a value
e:\aa\download\downloaddlg.h(41) : see declaration of 'OnOK'
E:\aa\download\downloadDlg.cpp(112) : error C2227: left of '->Read' must point to class/struct/union
E:\aa\download\downloadDlg.cpp(118) : error C2227: left of '->Close' must point to class/struct/union
E:\aa\download\downloadDlg.cpp(119) : error C2541: delete : cannot delete objects that are not pointers
Error executing cl.exe.download.exe - 10 error(s), 0 warning(s)