Where to get updated wininet.pas/dll?



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 ?


.



Relevant Pages

  • Re: Where to get updated wininet.pas/dll?
    ... 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. ... the jam up could be in a socket session and not in response ...
    (alt.comp.lang.borland-delphi)
  • Re: Application xxx has encountered a serious error and must shut
    ... it refers to errors in buffer management code - functions like strcpy etc. ... My app is a Managed C# CF3.5 app and makes extensive use of a TCP Socket ... NB I replaced the MS SerialPort with OpenNetCF Serial and this seems to ...
    (microsoft.public.windowsce.app.development)
  • Re: Conversion from UTF32 to UTF8 for review
    ... time, which puts a performance burden on the caller, which should be counted in the total ... you would, upon completion, put a NUL character at the end of the buffer. ... app or an MFC app; and if it were being graded on performance, I'd give it a D- at best, ... The programmer protested that "I have to do malloc each time because I ...
    (microsoft.public.vc.mfc)
  • Re: Tcl 8.4.5 with Expect 5.39 hangs waiting for data matching pattern
    ... At first I thought this was a bug in our scripts but after ... >> I actually added code to handle the incomplete buffer and process it. ... >> Are these know problems with either Tcl or Expect at these levels? ... > exists in 8.2 since I tried this release and ran into the same hang. ...
    (comp.lang.tcl)
  • Re: Writing Files asynchronously
    ... > I have a classic app that uses FSWrite to store text into a file. ... > app will hang indefinitely. ... > So I went looking for a way to kill off the pending I/O request. ...
    (comp.sys.mac.programmer.codewarrior)