精易论坛
标题: 读网络文件(API) [打印本页]
作者: stillness 时间: 2015-2-25 21:39
标题: 读网络文件(API)
本帖最后由 Modify 于 2015-2-25 21:52 编辑
变量名 | 类 型 | 静态 | 数组 | 备 注 |
hSession | 整数型 | | |
hFile | 整数型 | | |
buffer | 字节集 | | |
len | 整数型 | | |
null | 文本型 | | |
retVal | 字节集 | | |
hSession =
API_InternetOpen (null,
#INTERNET_OPEN_TYPE_PRECONFIG, null, null, 0
)
如果真 (hSession ≠
#NULL )
hFile =
API_InternetOpenUrl (hSession,
“http://img4.imgtn.bdimg.com/it/u=360413299,291033693&fm=116&gp=0.jpg”, null, 0,
#INTERNET_FLAG_RELOAD, 0
)
如果真 (hFile ≠
#NULL )

buffer =
取空白字节集 (512
)

循环判断首 ()

API_InternetReadFile (hFile, buffer, 512, len
)


retVal = retVal + buffer


循环判断尾 (len > 0
)
API_InternetCloseHandle (hFile
)
API_InternetCloseHandle (hSession)返回 (retVal)|
QueryFileSize | 整数型 | |
|
hRequest | 整数型 | | | |
buffer =
取空白文本 (127
)API_HttpQueryInfo (hRequest,
#HTTP_QUERY_CONTENT_LENGTH, buffer, 127, 0
)返回 (到整数 (buffer
))
#include <windows.h>
#include <wininet.h>
#pragma comment (lib, "Wininet.lib")
DWORD QueryFileSize (HANDLE hFile)
{
DWORD len = 127;
LPSTR str = new CHAR[len];
ZeroMemory (str, len);
HttpQueryInfo (hFile, HTTP_QUERY_CONTENT_LENGTH, str, &len, 0);
return atoi (str);
}
VOID HttpReadFile ()
{
HANDLE hSession = InternetOpen (NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL);
if (hSession != NULL)
{
HANDLE hFile = InternetOpenUrl (hSession, "http://wwww.baidu.com", NULL, NULL, INTERNET_FLAG_RELOAD, NULL);
if (hFile != NULL)
{
DWORD len;
LPBYTE buffer = new BYTE[512];
do
{
InternetReadFile (hFile, buffer, 512, &len);
RtlZeroMemory (buffer, len);
}
while (len > 0);
}
}
}
源码很短直接贴.打包比较费劲
-
1.jpg
(55.75 KB, 下载次数: 2)
作者: 黄米 时间: 2015-2-25 22:38
沙发是我的!~
作者: 夜的静night 时间: 2015-2-25 22:46
全部都是API 不容易啊
作者: Jelt 时间: 2015-2-26 13:45
火钳留名!!!!!
作者: 半睡半醒 时间: 2015-2-26 19:03
学习一下!!!
作者: xj839493922 时间: 2015-2-26 19:19
api不是在子版块么 顶一个
作者: yljgame520 时间: 2024-9-25 14:21
膜拜大佬
欢迎光临 精易论坛 (https://125.confly.eu.org/) |
Powered by Discuz! X3.4 |