MFC实现下载网络图片缓存到本地
来源:互联网 发布:ubuntu chrome 编辑:程序博客网 时间:2024/06/13 12:03
#include <afxinet.h>
新建一个基于对话框的工程,然后给确定按钮添加如下处理事件!【引入头文件afxinet.h】void CTestDlg::OnOK() {const int dwBufSize = 1024;CInternetSession * Session = new CInternetSession; CHttpFile* pHttpFile = NULL; CStdioFile pLocalFile; DWORD dwlen; try{ LPBYTE lpBuf = new byte[dwBufSize]; // 把这个szPath置为D://test.jpg就行了pLocalFile.Open( "D://test.jpg", CFile::modeCreate | CFile::modeWrite | CFile::typeBinary ); pHttpFile =(CHttpFile*)Session->OpenURL( "http://hiphotos.baidu.com/q252061160/pic/item/e4a5a9f010c6502bb17ec59d.jpg", 1, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE, NULL, 0); while(dwlen = pHttpFile-> Read(lpBuf, dwBufSize-1 )) { pLocalFile.Write(lpBuf,dwlen); } pLocalFile.Close(); pHttpFile->Close(); pHttpFile=NULL; delete[] lpBuf; }catch(CInternetException eInt) { eInt.Delete();} catch(CMemoryException eMem) { eMem.Delete(); } catch(CFileException eFile) { eFile.Delete(); } CDialog::OnOK();}http://blog.csdn.net/ccjjyy/article/details/6098104
新建一个基于对话框的工程,然后给确定按钮添加如下处理事件!【引入头文件afxinet.h】void CTestDlg::OnOK() {const int dwBufSize = 1024;CInternetSession * Session = new CInternetSession; CHttpFile* pHttpFile = NULL; CStdioFile pLocalFile; DWORD dwlen; try{ LPBYTE lpBuf = new byte[dwBufSize]; // 把这个szPath置为D://test.jpg就行了pLocalFile.Open( "D://test.jpg", CFile::modeCreate | CFile::modeWrite | CFile::typeBinary ); pHttpFile =(CHttpFile*)Session->OpenURL( "http://hiphotos.baidu.com/q252061160/pic/item/e4a5a9f010c6502bb17ec59d.jpg", 1, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE, NULL, 0); while(dwlen = pHttpFile-> Read(lpBuf, dwBufSize-1 )) { pLocalFile.Write(lpBuf,dwlen); } pLocalFile.Close(); pHttpFile->Close(); pHttpFile=NULL; delete[] lpBuf; }catch(CInternetException eInt) { eInt.Delete();} catch(CMemoryException eMem) { eMem.Delete(); } catch(CFileException eFile) { eFile.Delete(); } CDialog::OnOK();}http://blog.csdn.net/ccjjyy/article/details/6098104
0 0
- MFC实现下载网络图片缓存到本地
- MFC实现下载网络图片缓存到本地
- 下载网络图片到本地
- Android异步从网络下载图片并且缓存图片到本地的demo
- Android异步从网络下载图片并且缓存图片到本地的demo
- Android异步从网络下载图片并且缓存图片到本地的demo
- Android异步从网络下载图片并且缓存图片到本地的demo
- Android异步从网络下载图片并且缓存图片到本地的demo
- Android异步从网络下载图片并且缓存图片到本地的demo
- Android异步从网络下载图片并且缓存图片到本地的demo
- 从网络缓存图片到本地
- h5+的Downloader下载网络图片缓存到本地的案例
- Android 下载网络图片保存到本地
- c# 下载网络图片到本地
- php 下载网络图片到本地服务器
- java下载网络图片到本地
- python 下载网络图片到本地
- Android 下载网络图片保存到本地
- fiddler的使用
- ios 性能优化
- 循环语句的实战演练
- jenkins credentials & git ssh 认证
- JVM内幕:Java虚拟机详解
- MFC实现下载网络图片缓存到本地
- android studio 中配置 svn
- ZOJ 3522 Hide and seek
- Sine之舞
- 股票收益最大
- ubuntu 安装NVIDIA 显卡后分辨率改变成640*480解决办法
- mysql的binary、char、varchar区别
- 实现图片的无缝滚动
- OpenGL es 2.0 实战 - 渲染图形变形