Member Avatar for Thew
Thew

Hi,
I've got really strange problem.
I am using this function

function Download.GetInetFile(const fURL, FileName: String):boolean;
const
  BufferSize = 1024;
var
  hSession, hURL: HInternet;
  Buffer: array[1..BufferSize] of Byte;
  BufferLen: DWORD;
  f: File;
  sAppName: string;
  r:boolean;
begin
 r:=false;
 if Agent = '' then Agent := 'Server Status Controller, Matej Tomcik Production';
 sAppName := Agent;
 hSession := InternetOpen(PChar(sAppName), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, INTERNET_FLAG_RELOAD) ;
 InternetConnect(hSession,PChar(HostName),INTERNET_DEFAULT_HTTP_PORT,PChar(UserName),PChar(Password),INTERNET_SERVICE_HTTP,INTERNET_FLAG_PASSIVE,0);
 try
  hURL := InternetOpenURL(hSession, PChar(fURL), nil, 0, INTERNET_FLAG_PRAGMA_NOCACHE, 0) ;
  try
   AssignFile(f, FileName) ;
   Rewrite(f,1) ;
   repeat
    InternetReadFile(hURL, @Buffer, SizeOf(Buffer), BufferLen) ;
    BlockWrite(f, Buffer, BufferLen);
   until BufferLen = 0;
   CloseFile(f) ;
   r := True;
  finally
   InternetCloseHandle(hURL)
  end
 finally
  InternetCloseHandle(hSession)
 end;
 Result := r;
end;

to download a file from the internet.
To call this function, I am using a thread class. So it can be made asynchronyously with my running application.
So I compile and execute the application. After the timer ticks, I receive a message, that has this source "0". Simple. So, I have next one minute to the next timer's tick, and I rewrite the file on my website. I set it to the "1" value. But when the application shows the source, it's still the "0".
I used INTERNET_FLAG_PRAGMA_NOCACHE, but no result.

What should I do???
Any solutions?

PS: after the file is read, it's automatically deleted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.