Where to get updated wininet.pas/dll?
- From: "Ingolf" <Dont_Spam_ingolf@xxxxxxxxxx>
- Date: Sun, 17 Jul 2005 21:51:16 +0200
Hi
Have an app in D7 that downloads a file every N minutes.
Since in some rare cases the download will just hang and resulting in my app
to hang, i'm trying to implement a timeout in the filedownload.
I'm using wininet functions "InternetSetOption" with parameter
"INTERNET_OPTION_RECEIVE_TIMEOUT". But i can't get it to work correctly.
This is what i do
function GetInetFile(const fileURL, FileName: String): boolean;
var
hSession, hURL: HInternet;
sAppName: string;
ntimeout : dword;
f: file;
Buffer: array[0..8191] of Byte;
begin
sAppName := ExtractFileName(Application.ExeName);
hSession := InternetOpen(PChar(sAppName),
INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
if hSession=NIL then
begin
add2log('InternetOpen failed for file "'+filename+'"');
getinetfile:=false;
exit;
end;
nTimeOut := 5000; // 5 seconds
if not InternetSetOption(hSession , INTERNET_OPTION_RECEIVE_TIMEOUT ,
@nTimeOut , sizeof(ntimeout)) then
add2log('Error setting internetoptions, recieve_timeout!');
AssignFile(f, FileName);
Rewrite(f,1);
hURL := InternetOpenURL(hSession, PChar(fileURL), nil,0,0,0);
repeat
InternetReadFile(hURL, @Buffer, SizeOf(Buffer), BufferLen);
BlockWrite(f, Buffer, BufferLen);
until BufferLen<>sizeof(buffer);
CloseFile(f);
InternetCloseHandle(hURL);
InternetCloseHandle(hSession);
end;
It works.. kinda. The SetOption does not result in any error, but apparently
the timeout is still not set. So sometimes a file will hang the whole app.
:(
Apparently there is a bug in the wininet.dll:
http://support.microsoft.com/kb/q176420/#appliesto
But they say its fixed with IE v5, and i'm running with WinXp Sp2; IE v6. So
is there an update to the .PAS ?
.
- Follow-Ups:
- Re: Where to get updated wininet.pas/dll?
- From: Jamie
- Re: Where to get updated wininet.pas/dll?
- Prev by Date: Re: Empty bitmap...
- Next by Date: Re: Where to get updated wininet.pas/dll?
- Previous by thread: Empty bitmap...
- Next by thread: Re: Where to get updated wininet.pas/dll?
- Index(es):
Relevant Pages
|