关于Delphi7 获取网页的问题
delphi7,没发现那些httpid之类的控件
在网上找了个方法:
function GetWebPage(const Url: string):string;
var
Session,
HttpFile:HINTERNET;
szSizeBuffer:Pointer;
dwLengthSizeBuffer:DWord;
dwReserved:DWord;
dwFileSize:DWord;
dwBytesRead:DWord;
Contents:PChar;
begin
Session:=InternetOpen('',0,niL,niL,0);
HttpFile:=InternetOpenUrl(Session,PChar(Url),niL,0,0,0);
dwLengthSizeBuffer:=1024;
HttpQueryInfo(HttpFile,5,szSizeBuffer,dwLengthSizeBuffer,dwReserved);
GetMem(Contents,dwFileSize);
InternetReadFile(HttpFile,Contents,dwFileSize,dwBytesRead);
InternetCloseHandle(HttpFile);
InternetCloseHandle(Session);
Result:=StrPas(Contents);
FreeMem(Contents);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
a :string;
begin
a:=edit1.text;
if Pos('http://',a) = 0 then
begin
edit1.text:='http://' + edit1.text;
end;
Memo1.Text :=GetWebPage(edit1.Text);
end;
但是,这个显示网页不完全,而且很随即,有时候显示多有时候显示少.
我把那个1024后面加了3个0.有一次把sina首页全部显示了..但是更多的时候只显示很少的内容,这是为什么啊?
谁能给个delphi7获取网页的源码,谢谢各位大侠了.