求http下载文件的示例代码 想通过http的方式下载开了WEB服务的远程计算机上的文件。谁有类似的示例代码?一经提供,立即结贴。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Download a Web Page//this code excerpt also demonstrates how to use //try/catch exception handling#include <afxinet.h>//assumes server, port and URL names have been initializedCInternetSession session("My Session");CHttpConnection* pServer = NULL;CHttpFile* pFile = NULL;try{ CString strServerName; INTERNET_PORT nPort; pServer = session.GetHttpConnection(strServerName, nPort); pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, strObject); pFile->AddRequestHeaders(szHeaders); pFile->SendRequest(); pFile->QueryInfoStatusCode(dwRet); if (dwRet == HTTP_STATUS_OK) { UINT nRead = pFile->Read(szBuff, 1023); while (nRead > 0) { //read file... } } delete pFile; delete pServer;}catch (CInternetException* pEx){ //catch errors from WinInet}session.Close(); 我也有的很简单的,需要的话就留下mail [email protected]也给我一份学习一下!thanks. [email protected]我也想要一份,不过不知道能不能是SDK中的! 我发这个东西的时候总是被当作垃圾邮件挡回来了,不知道为什么-_-b刚刚又去搜了一下,你们看看这个吧^_^源码http://www.vckbase.com/code/network/internet/inet.zip文章http://www.vckbase.com/document/viewdoc.asp?id=319 求助 关于UpdateData的,到底该如何使用?? 求助:如何VC中单击按钮更新指定目录下的dll文件 菜鸟问题:如何修改打开文件对话框的标题? 求助:关于得到FTP服务器路径 初学MFC的困惑--我该选择MFC还是.Net?回复有分啊! 如何编程将dll/exe文件中的资源读取/显示出来 请大家帮忙:如何枚举win2k中所有登陆得域用户和他们机器得IP呀?! 不会做了 请各位帮忙啊 三层结构 水有GIF文件读写的源代码? 怎样学习ATL 如何利用pragma加入obj?
//this code excerpt also demonstrates how to use //try/catch exception handling
#include <afxinet.h>
//assumes server, port and URL names have been initialized
CInternetSession session("My Session");
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
try
{
CString strServerName;
INTERNET_PORT nPort; pServer = session.GetHttpConnection(strServerName, nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, strObject);
pFile->AddRequestHeaders(szHeaders);
pFile->SendRequest();
pFile->QueryInfoStatusCode(dwRet); if (dwRet == HTTP_STATUS_OK)
{
UINT nRead = pFile->Read(szBuff, 1023);
while (nRead > 0)
{
//read file...
}
}
delete pFile;
delete pServer;
}
catch (CInternetException* pEx)
{
//catch errors from WinInet
}
session.Close();
也给我一份学习一下!thanks.
我也想要一份,不过不知道能不能是SDK中的!
http://www.vckbase.com/code/network/internet/inet.zip
文章
http://www.vckbase.com/document/viewdoc.asp?id=319