Wininet笔记一-创新互联
1,
InternetOpen 创建根句柄,由下一层的 InternetOpenUrl 和 InternetConnect 使用,
而 InternetConnect 创建的句柄又被之后的几个函数使用。
HINTERNET InternetOpen(
_In_ LPCTSTR lpszAgent,
_In_ DWORD dwAccessType,
_In_ LPCTSTR lpszProxyName,
_In_ LPCTSTR lpszProxyBypass,
_In_ DWORD dwFlags
);Initializes an application's use of the WinINet functions.初始化winnet。
lpszAgent [in]
Pointer to a null-terminated string that specifies the name of the application or entity calling the WinINet functions. This name is used as the user agent in the HTTP protocol.
lpszAgent参数指定了调用wininet函数的应用程序或实体名称,并使用来填充http协议头的UserAgent字段。
2,
HINTERNET InternetOpenUrl(
_In_ HINTERNET hInternet,
_In_ LPCTSTR lpszUrl,
_In_ LPCTSTR lpszHeaders,
_In_ DWORD dwHeadersLength,
_In_ DWORD dwFlags,
_In_ DWORD_PTR dwContext
); Opens a resource specified by a complete FTP or HTTP URL.打开URL指定的资源。
lpszHeaders [in]
A pointer to a null-terminated string that specifies the headers to be sent to the HTTP server. For more information, see the description of the lpszHeaders parameter in the HttpSendRequest function.指定发送到server的http头信息。
dwContext [in]
A pointer to a variable that specifies the application-defined value that is passed, along with the returned handle, to any callback functions.一个指向一个应用程序定义的值,将随着返回的句柄,一起传递给回调函数。
3,
HINTERNET InternetConnect(
_In_ HINTERNET hInternet,
_In_ LPCTSTR lpszServerName,
_In_ INTERNET_PORT nServerPort,
_In_ LPCTSTR lpszUsername,
_In_ LPCTSTR lpszPassword,
_In_ DWORD dwService,
_In_ DWORD dwFlags,
_In_ DWORD_PTR dwContext
); Opens an File Transfer Protocol (FTP) or HTTP session for a given site.
lpszServerName [in]
Pointer to a null-terminated string that specifies the host name of an Internet server. Alternately, the string can contain the IP number of the site, in ASCII dotted-decimal format (for example, 11.0.1.45).主机的域名或IP地址。
nServerPort [in]
Transmission Control Protocol/Internet Protocol (TCP/IP) port on the server. These flags set only the port that is used.
dwContext [in]
同InternetOpenUrl设置传回掉函数的指针。
4,
5,
6,
HINTERNET HttpOpenRequest(
_In_ HINTERNET hConnect,
_In_ LPCTSTR lpszVerb,
_In_ LPCTSTR lpszObjectName,
_In_ LPCTSTR lpszVersion,
_In_ LPCTSTR lpszReferer,
_In_ LPCTSTR *lplpszAcceptTypes,
_In_ DWORD dwFlags,
_In_ DWORD_PTR dwContext
); Creates an HTTP request handle.
一旦和服务器的连接已经建立,我们打开了想要的文件。HttpOpenRequest去创建个请求句柄并且把参数存储在句柄中,HttpSendRequest把请求参数送到HTTP服务器。
lpszVerb指定请求的方法为"GET"、"PUT"或"POST",值填NULL默认为"GET"。
lpszObjectName指定页面地址,通常为文件名称、可执行模块或者查找标识符,如/MSDN/MSDNINFO/
lpszVersion标识HTTP版本,如"HTTP/1.1"
lpszReferer指定包含lpszObjectName文档的网址。
lplpszAcceptTypes表示客户接受的内容类型。如果该字符串为NULL,服务器认为客户接受"text/*"类型的文档 (也就是说,只有纯文本文档,并且不是图片或其它二进制文件)。内容类型与CGI变量CONTENT_TYPE相同,该变量确定了要查询的含有相关信息的 数据的类型,如HTTP POST和PUT。
分享题目:Wininet笔记一-创新互联
URL网址:http://scyanting.com/article/doogdg.html