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. Git 忽略特殊文件的功能

    有些时候,你必须把某些文件放到Git工作目录中.但是又不能提交他们,比如保存了数据库密码的配置文件等,每次git status都会 显示“untracked files”,如果有强迫症的你心里肯定不舒 ...

  2. 365DirMon(文件夹监视专家) v2.8绿色免费版

    软件名称:365DirMon(文件夹监视专家)软件语言: 简体中文授权方式: 免费软件运行环境: Win 32位/64位软件大小: 1.6M 图片预览: 软件简介:365DirMon 是一可以监控磁盘 ...

  3. SpringMvc之java文件下载

    首先强调,需要下载的文件只能放在项目中的webapp下 1.页面的一个超链接,链接到controller <a href="<%=path%>/download" ...

  4. 当用反射获取一个model,这个model里面字段有nullable的时候,获取字段真实类型

    Using Reflection to Determine whether an Type is Nullable And Get the underlying Type /// <summar ...

  5. MySql - JdbcType - Oracle类型映射

    MySql - JdbcType - Oracle类型映射   MySQL数据类型 JDBC TYPE Oracle数据类型 BIGINT BIGINT NUMBER(20) TINYINT TINY ...

  6. javaScript中的一些知识

    利用js动态生成table <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http ...

  7. 监控gc

    前几篇篇文章介绍了介绍了JVM的参数设置并给出了一些生产环境的JVM参数配置参考方案.正如之前文章中提到的JVM参数的设置需要根据应用的特性来进行设置,每个参数的设置都需要对JVM进行长时间的监测,并 ...

  8. HDU - 5547 Sudoku(数独搜索)

    Description Yi Sima was one of the best counselors of Cao Cao. He likes to play a funny game himself ...

  9. # Linux Whois3获取 运营商信息

    Linux Whois3获取 运营商信息 APNIC是管理亚太地区IP地址分配的机构,它有着丰富准确的IP地址分配库,同时这些信息也是对外公开的,并提供了一个查询工具,下面就让我们看看如何在Linux ...

  10. HDU 4381 Grid

    背包变形. 将操作分为了两类,可以分开处理. 可以dp处理出L[i]:L[i]=-1代表从左到右 i 长度不能被拼凑出来,L[i]!=-1表示从左到右 i 长度能被拼凑出,并且最小费用为L[i]. 反 ...