/*
@author:CodingMengmeng
@theme:C++根据图片url下载图片
@time:2017-1-6 22:58:00
@blog:http://www.cnblogs.com/codingmengmeng/
*/
#include <tchar.h>
#include <iostream>
#include <urlmon.h>
/*
#pragma comment(lib,"urlmon.lib")作用:
连接静态库到项目中,效果等同于:
项目属性——链接器——输入——附加依赖项中加入这个lib
(头文件<urlmon.h>中只是包含了数据结构和函数声明,是编译阶段;
链接阶段将从静态库中恢复这些函数和数据并把他们和应用程序中的其它模块组合在一起生成可执行文件,
该过程称为“静态链接”)
*/
#pragma comment(lib,"urlmon.lib")
using namespace std;
int _tmain(int argc, char* argv[])
{
string url = "http://pic104.nipic.com/file/20160715/6171480_185807154956_2.jpg";
size_t len = url.length();//获取字符串长度
int nmlen = MultiByteToWideChar(CP_ACP, 0, url.c_str(), len + 1, NULL, 0);//如果函数运行成功,并且cchWideChar为零,
//返回值是接收到待转换字符串的缓冲区所需求的