http协议使用实例
#include <stdio.h>
#include <windows.h>
#include <wininet.h>
#define MAXSIZE 1024
#pragma comment(lib, "Wininet.lib")
void urlopen(TCHAR*);
int main(int argc, TCHAR* argv[])
{
TCHAR ch[] = TEXT("http://dt.163.com/images/news/0605/news02053101_5.jpg");
urlopen(ch);
getchar();
return 0;
}
void urlopen(TCHAR* url)
{
HINTERNET hSession = InternetOpen(TEXT("UrlTest"), INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY, NULL, NULL, 0);
if(hSession != NULL)
{
HINTERNET hHttp = InternetOpenUrl(hSession, url, NULL, 0, INTERNET_FLAG_DONT_CACHE, 0);
BYTE Temp[MAXSIZE];
ULONG Number = 1;
DWORD written;
HANDLE hFile;
if (hHttp != NULL)
{
wprintf_s(TEXT("%s\n"), url);
hFile = CreateFile( TEXT("ysl.jpg"),GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
if ( hFile == INVALID_HANDLE_VALUE )
{
goto hear;
}
while (Number > 0)
{
InternetReadFile(hHttp, Temp, MAXSIZE - 1, &Number);
Temp[Number] = '\0';
WriteFile( hFile,Temp,Number, &written,NULL);
}
InternetCloseHandle(hHttp);
hHttp = NULL;
}
hear:
CloseHandle( hFile );
InternetCloseHandle(hSession);
hSession = NULL;
}
}
http协议使用实例的更多相关文章
- MTK MT33xx型GPS的NMEA协议解析实例
1)解析实现 gps_main.c #include <nmea/nmea.h> #include <string.h> #include <stdio.h> #i ...
- Swift2.1 语法指南——协议
原档: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programm ...
- RDP协议
远程桌面协议 (RDP),用于终端服务器和终端服务器客户端之间的通信.RDP 被封装并在 TCP 加密. 远程桌面协议基于,并是对扩展 T 系列的协议标准. 多声道支持协议用于单独的虚拟通道储存的演示 ...
- 学习Swift -- 协议(下)
协议(下) 在拓展中添加协议成员 通过扩展使得Dice类型遵循了一个新的协议,这和Dice类型在定义的时候声明为遵循TextRepresentable协议的效果相同.在扩展的时候,协议名称写在类型名之 ...
- SKPhysicsContactDelegate协议
符合 NSObject 框架 /System/Library/Frameworks/SpriteKit.framework 可用性 可用于iOS .0或者更晚的版本 声明于 SKPhysicsWorl ...
- swift 笔记 (十九) ——
协议
协议(Protocols) 协议仅是用定义某些任务或者是功能必须的方法和属性. 类似于java里的interface的作用.但协议并不会实现详细的功能. 我猜这个名字源于OO中提到的"契约& ...
- locust压测rpc协议
这里主要是google的grpc接口进行压测的一个栗子. Locust是以HTTP为主要目标构建的. 但是,通过编写钩子触发器request_success和 request_failure事件的自定 ...
- locust压测websocket协议
Locust是以HTTP为主要目标构建的. 但是,通过编写触发器request_success和 request_failure事件的自定义客户端,可以轻松扩展到任何基于请求/响应的系统的负载测试 . ...
- 译《The Part-Time Parliament》——终于读懂了Paxos协议!
最近的考古发现表明,在Paxos小岛上,尽管兼职议会成员都有逍遥癖,但议会模式仍然起作用.他们依旧保持了一致的会议记录,尽管他们频繁的进出会议室并且他们的信使还很健忘.Paxon议会协议提供了一种新方 ...
随机推荐
- SQL SERVER 执行远端数据库的SQL命令
--------------------------------------------------------------这段先执行exec sp_configure 'show advanced ...
- tomcat7源代码Bootstrap
tomcat的启动从bootstrap的main方法開始,在main方法中主要是做了三件事,调用init方法初始化自己.调用catalinaDaemon对象 的setAwait方法设置它的await属 ...
- msxml 操作xml
1.简介 在.NET平台,微软为C#或托管C++程序员提供了丰富的类库,用以支持各种需求,其中就有对XML文件操作的丰富的类.例如XMLDocument, XmlElement等.但是C++标准库中并 ...
- Can a Tomcat docBase span multiple folders?--转
Question: I apologize if this is a poor question, but I'm using Windows and looking to see if there' ...
- Java – 4 Security Vulnerabilities Related Coding Practices to Avoid---reference
This article represents top 4 security vulnerabilities related coding practice to avoid while you ar ...
- [转] IPC之管道、FIFO、socketpair
管道和FIFO作为最初的UNIX IPC形式,现在已用得较少.SocketPair可作为全双工版本的管道,较为常用,这里简单做个笔记 管道 * 只用于有亲缘关系的进程间通信 * 单向,即半双工 (双向 ...
- /etc/motd and /etc/issue
/etc/motd and /etc/issue Bash offers an option to include messages in the /etc/motd and the /etc/iss ...
- web第一节课 sql 数据库连接 查询
1.数据库连接语句 <connectionStrings> <add name="yhotel" connectionString="Database= ...
- css3 3D变换和动画
3D变换和动画 建立3D空间,transform-style: preserve-3d perspective: 100px; 景深 perspective-origin:center center ...
- 在ASP.NET中使用一般处理程序生成验证码
如果期望一般处理程序(ashx)处理Session,必须实现[System.Web.SessionState]命名空间下的[IRequiresSessionState]接口. asp.net中的验证码 ...