InternetOpen:

Initializes an application's use of the WinINet functions.

HINTERNET InternetOpen(
_In_ LPCTSTR lpszAgent,
_In_ DWORD dwAccessType,
_In_ LPCTSTR lpszProxyName,
_In_ LPCTSTR lpszProxyBypass,
_In_ DWORD dwFlags
);

Remarks

InternetOpen is the first WinINet function called by an application. It tells the Internet DLL to initialize internal data structures and prepare for future calls from the application. When the application finishes using the Internet functions, it should call InternetCloseHandle to free the handle and any associated resources.

InternetOpenUrl:

Opens a resource specified by a complete FTP or HTTP URL.

HINTERNET InternetOpenUrl(
_In_ HINTERNET hInternet,
_In_ LPCTSTR lpszUrl,
_In_ LPCTSTR lpszHeaders,
_In_ DWORD dwHeadersLength,
_In_ DWORD dwFlags,
_In_ DWORD_PTR dwContext
);

InternetReadFile:

Reads data from a handle opened by the InternetOpenUrl, FtpOpenFile, or HttpOpenRequest function.

BOOL InternetReadFile(
_In_ HINTERNET hFile,
_Out_ LPVOID lpBuffer,
_In_ DWORD dwNumberOfBytesToRead,
_Out_ LPDWORD lpdwNumberOfBytesRead
);
#include <windows.h>
#include <WinInet.h>
#include <iostream>
#pragma comment(lib,"wininet.lib") using namespace std; int DownLoader()
{
DWORD dwByteRead = ;
char szDownBuffer[];
memset(szDownBuffer, , );
BOOL bIntNetReadFile = TRUE;
BOOL bWriteFile = TRUE;
DWORD dwWritten = ; HINTERNET hintInternetOpen = InternetOpen("Testing", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, );
if (!hintInternetOpen)
{
InternetCloseHandle(hintInternetOpen);
return ;
}
HINTERNET hintInternetOpenUrl = InternetOpenUrl(hintInternetOpen, "http://w.x.baidu.com/go/mini/2/10100", NULL, , INTERNET_FLAG_RELOAD, );
if (!hintInternetOpenUrl)
{
InternetCloseHandle(hintInternetOpen);
InternetCloseHandle(hintInternetOpenUrl);
return ;
} HANDLE hCreateFile = CreateFile("D:\\BaiDu2.exe", GENERIC_WRITE, , , CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, );
if (hCreateFile == INVALID_HANDLE_VALUE)
{
InternetCloseHandle(hintInternetOpen);
InternetCloseHandle(hintInternetOpenUrl);
return ;
} while (bIntNetReadFile && bWriteFile)
{
bIntNetReadFile = InternetReadFile(hintInternetOpenUrl, szDownBuffer, sizeof(szDownBuffer), &dwByteRead);
if (!dwByteRead)
{
break;
} bWriteFile = WriteFile(hCreateFile, szDownBuffer, sizeof(szDownBuffer), &dwWritten, NULL);
if (!dwWritten)
{
break;
}
} InternetCloseHandle(hintInternetOpen);
InternetCloseHandle(hintInternetOpenUrl);
return ;
} int main()
{
DownLoader();
system("pause");
return ;
}

D盘下生成了下载的文件:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAk4AAAAbCAIAAAAF55fPAAAHFklEQVR4nO2d728URRjH+29dQjQqGiNBJUaNUUBjLhrihgRiCP5AYkg2BD3EXzUYXGIiUaNBc76YVwKBBG2QfSEpB4KBxC1t77hyttce7fb0xd7uPPNz97a9Uva+n1ya3swzs3t3s/Od55nZ2ZGwf25efOOfS/tvXNxz/fedV8+9NnZy49kTj1xmT/59pve6fubpa+d3qwWr5VKlFv0zoqdcDcOwVikZskd65QEoKL7nuCxYuU2RYK7jOI7na7KCKC/6OgLmSka+R4v5nrGeKEufBwrBSI4yE+OVK2e3j5/eOn5q2/ipl8dObjxzYtMl9tzl09sun9o6/utL187vqt/4ZdXPFYCiA6UDYCDkkbowDDvt6fpNdvW3fReqm8/99Opf/g/z/+LiAwAAsB7JKXUAAADA/QKkDgAAQMGB1AEAACg4kDoAAAAFB1IHAACg4EDqAAAAFJy+pe7wx6N9vQZx0gAAAEB28kjdn1dumF6v7z1C/0LqAAAA3HPySN3YhT8yvlYkdbVKCRuBAQAkxO2+EnqbhOkhBQLmOo7LfMVcVym2pikKeaTuP4Vut9vtdpeXl5eWlu7evTs/Pz83N9dqtVSpE3a/tAsZlzppU8xytd+TBmBAkP5V2W0x2ZxRSKYdamKn2oYBcyNbfgil001sdJWLBzBs76iW0n8i+wknyWuziaR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y1F6iBuIC/yJWYL7GSSOrOR6OzJNpoAZt9Sl1UgTZmDCmH2PC2qdZ5PA5mhqnuaFZgeCxIrdTLO8CxzcVHE8CpdSutVQgNyQ1InRx3HY7pE+Rhx7dSRTKrN1lpXcrNBt9sN4ym6drsdTdHduXOn2WzW6/Wpqalbt25l9eqkGTy71FXLI4I1kUheMEoU3MZqmc/LlSo1UlRvBkAaWseH9Aj26TTiW5ARq7FDSZuZ0MiqOtmm/QiiZ6QsauOJuhMm0pDiB+aHLpuk43hpZYP46RWp8xkLlE5Z8ep8yT8xHHwIydIyBWNL8+troCStwNR7gQPy6lSpm52dbbVazWaz0WhMTU1NTk5OTEykzNVxfeHBy1K5rPXqTOHFJE8sKCgnPRgRSrJCRV0UA0AqsmNAlUgaoMrRNTrJQYsq/SkvaF7vZqicnJ+uD9CXoqmaqT71hIUig/F5tM6UerOAUfi0NxvwPHUpYPrRhwttUzG0TCGUb2wWeaUurjaOX9ucQRHsgQnAOiJLBHBwCx3XJ5H62KbiPF+jYPT+AmHwL994wHE9T1RIRdaBlXU8LMCTDQBYP0DpwH1Mltsf7xWQOgAAAAUHUgcAAKDgQOoAAAAUHEgdAACAgvM/Cs4pdaSNQewAAAAASUVORK5CYII=" alt="" />

 如果改为动态调用

#include <windows.h>
#include <iostream>
#include "dynamicfreetokill.h" using namespace std; int main()
{ cout << hmWinINetDLL << endl;
if (!hmWinINetDLL)
{
cout << "HMDOULE" << endl;
}
pfINTERNETCRACKURL pfInternetCrackUrl = (pfINTERNETCRACKURL)GetProcAddress(hmWinINetDLL, "InternetCrackUrlW");
cout << pfInternetCrackUrl << endl;
if (!pfInternetCrackUrl)
{
cout << "InternetCrackUrlW" << endl;
}
pfINTERNETOPEN pfInternetOpen = (pfINTERNETOPEN)GetProcAddress(hmWinINetDLL, "InternetOpenW");
cout << pfInternetOpen << endl;
if (!pfInternetOpen)
{
cout << "InternetOpenW" << endl;
}
pfINTERNETCONNECT pfInternetConnect = (pfINTERNETCONNECT)GetProcAddress(hmWinINetDLL, "InternetConnectW");
cout << pfInternetConnect << endl;
if (!pfInternetOpen)
{
cout << "InternetConnectW" << endl;
}
pfHTTPOPENREQUEST pfHttpOpenRequest = (pfHTTPOPENREQUEST)GetProcAddress(hmWinINetDLL, "HttpOpenRequestW");
cout << pfHttpOpenRequest << endl;
if (!pfInternetOpen)
{
cout << "HttpOpenRequestW" << endl;
}
pfINTERNETSETOPTION pfInternetSetOption = (pfINTERNETSETOPTION)GetProcAddress(hmWinINetDLL, "InternetSetOptionW");
cout << pfInternetSetOption << endl;
if (!pfInternetOpen)
{
cout << "InternetSetOptionW" << endl;
}
pfHTTPSENDREQUEST pfHttpSendRequest = (pfHTTPSENDREQUEST)GetProcAddress(hmWinINetDLL, "HttpSendRequestW");
cout << pfHttpSendRequest << endl;
if (!pfInternetOpen)
{
cout << "HttpSendRequestW" << endl;
}
pfHTTPQUERYINFO pfHttpQueryInfo = (pfHTTPQUERYINFO)GetProcAddress(hmWinINetDLL, "HttpQueryInfoW");
cout << pfHttpQueryInfo << endl;
if (!pfInternetOpen)
{
cout << "HttpQueryInfoW" << endl;
}
pfINTERNETCLOSEHANDLE pfInternetCloseHandle = (pfINTERNETCLOSEHANDLE)GetProcAddress(hmWinINetDLL, "InternetCloseHandle");
cout << pfInternetCloseHandle << endl;
if (!pfInternetOpen)
{
cout << "InternetCloseHandle" << endl;
}
pfINTERNETSETFILEPOINTER pfInternetSetFilePointer = (pfINTERNETSETFILEPOINTER)GetProcAddress(hmWinINetDLL, "InternetSetFilePointer");
cout << pfInternetSetFilePointer << endl;
if (!pfInternetOpen)
{
cout << "InternetSetFilePointer" << endl;
}
pfINTERNETGETLASTRESPONSEINFO pfInternetGetLastResponseInfo = (pfINTERNETGETLASTRESPONSEINFO)GetProcAddress(hmWinINetDLL, "InternetGetLastResponseInfoW");
cout << pfInternetGetLastResponseInfo << endl;
if (!pfInternetOpen)
{
cout << "InternetGetLastResponseInfoW" << endl;
}
pfINTERNETREADFILE pfInternetReadFile = (pfINTERNETREADFILE)GetProcAddress(hmWinINetDLL, "InternetReadFile");
cout << pfInternetReadFile << endl;
if (!pfInternetOpen)
{
cout << "InternetReadFile" << endl;
} FreeLibrary(hmWinINetDLL);
system("pause");
return ;
}

Windows API 之 InternetOpen、InternetOpenUrl、InternetReadFile的更多相关文章

  1. C# Windows API

    API:应用程序接口(API:Application Program Interface)应用程序接口(API:application programming interface)是一组定义.程序及协 ...

  2. Windows API 函数列表 附帮助手册

    所有Windows API函数列表,为了方便查询,也为了大家查找,所以整理一下贡献出来了. 帮助手册:700多个Windows API的函数手册 免费下载 API之网络函数 API之消息函数 API之 ...

  3. Windows API Hooking in Python

    catalogue . 相关基础知识 . Deviare API Hook Overview . 使用ctypes调用Windows API . pydbg . winappdbg . dll inj ...

  4. 初识【Windows API】--文本去重

    最近学习操作系统中,老师布置了一个作业,运用系统调用函数删除文件夹下两个重复文本类文件,Linux玩不动,于是就只能在Windows下进行了. 看了一下介绍Windows API的博客: 点击打开 基 ...

  5. C#调用windows API的一些方法

    使用C#调用windows API(从其它地方总结来的,以备查询) C#调用windows API也可以叫做C#如何直接调用非托管代码,通常有2种方法: 1.  直接调用从 DLL 导出的函数. 2. ...

  6. Qt中使用Windows API

    在Windows平台上进行开发,不可避免与Windows API打交道,Qt中使用的时候要添加对应API的头文件和链接lib文件,另外使用的Windows API的代码部分要使用#ifdef  Q_O ...

  7. 在VBA中使用Windows API

    VBA是一种强大的编程语言,可用于自定义Microsoft Office解决方案.通过使用VBA处理一个或多个Office应用程序对象模型,可以容易地修改Office应用程序的功能或者能够使两个或多个 ...

  8. FormatMessage与GetLastError配合使用,排查windows api调用过程中的错误

    前一段时间在学习windows api调用过程中,遇到过一些调用错误或者程序没能显示预期的结果,或者直接出现vc运行时错误. 这对新手来说是司空见惯的事,因为不太熟悉难免会出错,出错的信息如果能显示很 ...

  9. C#调用Windows API函数截图

    界面如下: 下面放了一个PictureBox 首先是声明函数: //这里是调用 Windows API函数来进行截图 //首先导入库文件 [System.Runtime.InteropServices ...

随机推荐

  1. iOS应用性能调优的4个建议和技巧

    任何一个能在用户手机屏幕中占有一席之地的iOS app都包含3个关键因素:想法好.设计出色.性能卓越.本文将分享一些iOS应用性能调优的4个建议和技巧. Tip #1:把图片资源压缩到最小.    i ...

  2. 带宽 VS CDN (转载)

    并发的影响因素:带宽.web server(含php).static server.数据库 带宽价格: 静态IP企业宽带 5M 10M 50M 100M 200M 盛大云 华东双线 216/月 396 ...

  3. go pkg

    fmt Scanln用来读取输入数据 示例: package main import ( "fmt" "os" "time" ) func ...

  4. Value '0000-00-00' can not be represented as java.sql.Date

    Value '0000-00-00' can not be represented as java.sql.Date 时间 2014-07-30 09:00:50 ITeye-博客 原文  http: ...

  5. 全排列dfs算法

    如下 #include <iostream> using namespace std; #define MAX 10 #define _CRT_SECURE_NO_WARNINGS int ...

  6. linux下写脚本时-gt是什么意思

    -eq 等于-ne 不等于-gt 大于-ge 大于等于-lt 小于-le 小于等于

  7. linex下部署发布web项目

    准备工作:通过Xmanager远程连接linux系统,下载对应的jdk和tomcat. 1.通过Xmanager远程连接linux系统,下载地址请自己网上搜索吧. 2.下载jdk (这里为jdk-7u ...

  8. Java 处理图片 base64 编码的相互转换

    哈喽大家好我是刘德华. 今天项目优化了一下上传头像的功能.采用 imagecropper 插件完成裁剪图片的效果. 这个插件裁剪完的图片都是 base64 加密的字符串,上传头像也就涉及到了如何把加密 ...

  9. ASP.NET弹出提示点击确定之后再跳转页面的方法

    //ASP.NET弹出提示点击确定之后再跳转页面的方法 //弹出了提示并且通过location.href转到了DeskTop.aspx页面 Response.Write("<scrip ...

  10. 网页特效-动态加载JavaScript

    描述: 把一些逻辑独立的JavaScript脚本文件单独加载,是一种常见的JavaScript动态加载技术.可以减少不必要的JavaScript脚本文件的加载,以提高网页浏览速度 代码: <!D ...