Registriert seit: 5. Okt 2004
36 Beiträge
|
Re: quellcode aus dem internet laden
4. Nov 2004, 19:46
so hier ist die antwort:
Delphi-Quellcode:
Function GetHTML(AUrl: string): string;
var
databuffer : array[0..4095] of char;
ResStr : string;
hSession, hfile, hRequest: hInternet;
dwindex,dwcodelen,datalen,dwread,dwNumber: cardinal;
dwcode : array[1..20] of char;
res : pchar;
Str : pchar;
begin
ResStr:='';
if pos('http://',lowercase(AUrl))=0 then
AUrl:='http://'+AUrl;
hSession:=InternetOpen('InetURL:/1.0',
INTERNET_OPEN_TYPE_PRECONFIG,
nil,
nil,
0);
if assigned(hsession) then
begin
hfile:=InternetOpenUrl(
hsession,
pchar(AUrl),
nil,
0,
INTERNET_FLAG_RELOAD,
0);
dwIndex := 0;
dwCodeLen := 10;
HttpQueryInfo(hfile,
HTTP_QUERY_STATUS_CODE,
@dwcode,
dwcodeLen,
dwIndex);
res := pchar(@dwcode);
dwNumber := sizeof(databuffer)-1;
if (res ='200') or (res ='302') then
begin
while (InternetReadfile(hfile,
@databuffer,
dwNumber,
DwRead)) do
begin
if dwRead =0 then
break;
databuffer[dwread]:=#0;
Str := pchar(@databuffer);
resStr := resStr + Str;
end;
end
else
ResStr := 'Status:'+res;
if assigned(hfile) then
InternetCloseHandle(hfile);
end;
InternetCloseHandle(hsession);
Result := resStr;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Text:=GetHTML('http://www.lsf-wesel.de')
end;
end.
mfg elle
Michael Wissen ist Macht!
|
|
Zitat
|