I figured it out.
I needed to change one line
Changed From:
lpBuffer: array[0..1024 + 1] of Char;
Changed To:
lpBuffer: array[0..$400 - 1] of AnsiChar;
----- Original Message -----
From: "SoftTech" <mi...@softtechks.com>
To: "Delphi - Talk" <delphi-talk@elists.org>
Sent: Wednesday, January 19, 2011 8:56 AM
Subject: Converting DownloadURL_NOCache() function to work with Delphi 2010
I downloaded and used the DownloadURL_NOCache() from the Swiss Delphi
Center and have been using it without issue in Delphi 5
You can find it here
http://www.swissdelphicenter.ch/en/showcode.php?id=412
function DownloadURL_NOCache(const aUrl: string; var s: String): Boolean;
var
hSession: HINTERNET;
hService: HINTERNET;
lpBuffer: array[0..1024 + 1] of Char;
dwBytesRead: DWORD;
begin
Result := False;
s := '';
hSession := InternetOpen('MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil,
nil, 0);
try
if Assigned(hSession) then
begin
hService := InternetOpenUrl(hSession, PChar(aUrl), nil, 0,
INTERNET_FLAG_RELOAD, 0);
if Assigned(hService) then
try
while True do
begin
dwBytesRead := 1024;
InternetReadFile(hService, @lpBuffer, 1024, dwBytesRead);
if dwBytesRead = 0 then break;
lpBuffer[dwBytesRead] := #0;
s := s + lpBuffer;
end;
Result := True;
finally
InternetCloseHandle(hService);
end;
end;
finally
InternetCloseHandle(hSession);
end;
end;
This does not work with Delphi 2010. The lpBuffer is full of garbage.
Can anyone help?
Thanks,
Mike
__________________________________________________
Delphi-Talk mailing list -> Delphi-Talk@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk
--
MailScanner Virus/Spam/Malware: PASS (GZ)
__________________________________________________
Delphi-Talk mailing list -> Delphi-Talk@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk