function LoadFromURL(
url:
string;
var Data:
string):Boolean;
const BufferSize = 256;
var Buffer :
array[1..BufferSize]
of char;
BufferLen : DWORD;
ok : Boolean;
hSession : HInternet;
hHttp : HInternet;
hUrl : HInternet;
begin
result:=false;
data:='
';
try //ProxyServer = proxy-....
hSession := InternetOpen(
{PChar('Agent')}nil,
{INTERNET_OPEN_TYPE_PROXY}INTERNET_OPEN_TYPE_PRECONFIG,
{PChar('proxy-.....')}nil,
{PChar('passwort')}nil,0);
if hSession =
nil then
begin
Showmessage('
Kann nicht auf WinInit.DLL zugreifen');
exit;
end;
hHttp := InternetConnect(hSession,'
http://...',
INTERNET_DEFAULT_HTTP_PORT,
nil,
nil,INTERNET_SERVICE_HTTP,0,0);
if hHttp =
nil then
begin
Showmessage('
Es besteht keine Verbindung zum "Intranet"');
exit;
end;
hURL := InternetOpenURL(hSession,PChar(
URL),
nil,0,INTERNET_FLAG_RELOAD,0);
if hURL =
nil then
begin
exit;
end
except
exit;
end;
try
if hURL <>
nil then
begin
repeat
ok := InternetReadFile(hURL, @Buffer, SizeOf(buffer), BufferLen);
if not ok
then
begin
data:='
';
result:=false;
exit;
end;
data:=data+copy(buffer,1,bufferlen);
until bufferlen<SizeOf(Buffer);
Result:=True;
end;
finally
InternetCloseHandle(hURL);
InternetCloseHandle(hSession);
InternetCloseHandle(hHttp);
end;
end;