我以前在网上找到一个函数,不用任何控件就可以下载网页文件,我稍做了些修改,出处
也不记得了,先声明:不是我的原创。
--------------------------------------------------------------------------
uses WinInet;
function DownloadFile(const remoteurl:string):String;
var
content:string;
NetHandle: HINTERNET;
UrlHandle:HINTERNET;
BytesRead
WORD;
Buffer:array[1..1024]of Char;
begin
NetHandle:=InternetOpen('htmlcopy 0.4b',
INTERNET_OPEN_TYPE_DIRECT,
nil,
nil,
0);
if Assigned(NetHandle)then
begin
UrlHandle:= InternetOpenUrl(NetHandle,
PChar(remoteurl),
nil,
0,
INTERNET_FLAG_RELOAD,
0);
if Assigned(UrlHandle) then
begin
content:='';
repeat
FillChar(Buffer, SizeOf(Buffer),0);
InternetReadFile(UrlHandle,
@Buffer[1],
SizeOf(Buffer),
BytesRead);
content:=content+copy(Buffer,1,bytesread);
until BytesRead=0;
end;
InternetCloseHandle(UrlHandle);
end;
InternetCloseHandle(NetHandle);
Result:=content;
//String2File(content, tmpPath+sTempHtmlFile);
end;
to 深之蓝:
难道你点击网页上的链接,它会无动于衷?呵呵
WebBrowser本来就有WebBrowser.forward、WebBrowser.goback的功能