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. 快速进入pycharm图形界面

    解压后的pycharm相关文件的路径:/home/hadoop2/下载/pycharm-community-4.5.4 添加快速启动pycharm命令: (1)进入/usr/local/sbin这个目 ...

  2. 第一题 (Map)利用Map,完成下面的功能:

    从命令行读入一个字符串,表示一个年份,输出该年的世界杯冠军是哪支球队.如果该 年没有举办世界杯,则输出:没有举办世界杯.  附:世界杯冠军以及对应的夺冠年份,请参考本章附录. 附录  1.历届世界杯冠 ...

  3. UI----安健1 button lable textfiend

    //按钮 UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect ];//按钮形状 button.frame = CGR ...

  4. PHP实现中文截取无乱码

    字符串的处理是编程中比较常见的,各种编程语言对字符串的处理也提供了大量函数,像php中mb_substr()函数可以实现对中文字符串的截取,如何使用自定义方法实现中文字符串截取无乱码这也是面试经常遇到 ...

  5. java类中为什么设置set和get方法操作属性

    java程序规范中会建议大家尽量将类中的属性私有化,即定义为private变量,通过设置set和get函数来对属性进行操作.一些人存在这样的疑问,为什么不直接将属性设置为public,以后调用属性时直 ...

  6. Spring 框架理论基础

    一. IOC 控制反转 概念解释:当我需要一个资源时,容器已经帮我准备好,我只需要接受就可以. // 加载 IOC 容器 ApplicationContext ac = new ClassPathXm ...

  7. 使用Common.Logging与log4net的组件版本兼容问题

    引用:  http://www.cnblogs.com/shijun/p/3713830.html 近期使用了Common.Logging的ILog接口做日志接口,同时利用其log4net适配器与lo ...

  8. 手把手教你ranorex_android自动化测试第一个示例

    要说android的自动化,那真是折腾死我了,从早期的monkeyrunner,到后来的robotium,再到最新的uiautomator,各有各的问题,总之性价比都不够高,不太适合我的使用场景.于是 ...

  9. 如何使用SecureCRT连接ubuntu

    1. 首先要明白什么是ssh? 可以把ssh看做是telnet的加强版,telnet的密码和信息都是不加密的,而ssh则加密. .2. 开启ubuntu上的ssh功能 先安装,安装后就自动开启了. s ...

  10. ADT(abstract data types)抽象数据类型

    1.What is it? An abstract data type is a set of objects together with a set of operations. 抽象数据类型是带有 ...