Lazarus

Programming => Packages and Libraries => Ported from Delphi/Kylix => Topic started by: Onjahyr-BR on September 25, 2006, 08:28:31 pm

Title: urlmon for lazarus - convert possible?
Post by: Onjahyr-BR on September 25, 2006, 08:28:31 pm
:lol:

http://www.articles.org.ru/cfaq/index.php?qid=243&frommostrecent=yes

where urlmon

Code: [Select]

downloadfile('http://some.com/some.zip', 'c:some.zip');

function downloadfile(const fileurl, filename: string): cardinal;
var
hsession, hfile: hinternet;
buffer: array[1..1024] of byte;
bufferlen, fsize: longword;
f: file;
begin
result := 0;
hsession := internetopen('steroid download',
internet_open_type_preconfig, nil, nil, 0);
if assigned(hsession) then begin
hfile := internetopenurl(hsession, pchar(fileurl), nil, 0,
internet_flag_reload, 0);
if assigned(hfile) then begin
assignfile(f, filename);
rewrite(f,1);
fsize := 0;
repeat
internetreadfile(hfile, @buffer, sizeof(buffer), bufferlen);
blockwrite(f, buffer, bufferlen);
fsize := fsize + bufferlen;
until (bufferlen = 0);
closefile(f);
result := fsize;
internetclosehandle(hfile);
end;
internetclosehandle(hsession);
end;
end;


see link
Title: RE: urlmon for lazarus - convert possible?
Post by: Marc on September 26, 2006, 10:46:12 am
It might be possible if you know what unit they used for:
  internetopen, internetopenurl, internetreadfile, internetclosehandle
Title: RE: urlmon for lazarus - convert possible?
Post by: CCRDude on September 26, 2006, 11:09:11 am
Here (http://ccrdu.de/files/fpc/pkWinINet.pas) is a unit from myself that uses those Internet* functions to do a HTTP download (including declaration of the necessary functions from wininet.dll, basic error handling and events for progress etc.). You can remove pkStrings from the uses and replace all StringsString with string, that is just a wrapper to have the proper type for Unicode WinCE or Ansi Win32.
Title: RE: urlmon for lazarus - convert possible?
Post by: Onjahyr-BR on September 26, 2006, 01:06:00 pm
it forgives, using the Linux
Title: RE: urlmon for lazarus - convert possible?
Post by: CCRDude on September 26, 2006, 01:42:48 pm
"forgives"? yes, it does not work under Linux, I thought you were looking for an implementation using Internet* functions? Those are Windows only of course! And you asked especially for urlmon. urlmon is Windows specific! Maybe you could wrote more than two quarter sentences the next time?

For all platforms except WinCE, but including Unix, why don't you use Synapse? It's really discussed in every tenth post here ;) Just use function HttpGetBinary (http://www.ararat.cz/synapse/docs/help/index.html) from unit httpsend.
Title: urlmon for lazarus - convert possible?
Post by: Onjahyr-BR on September 26, 2006, 01:58:24 pm
It is, I already vi this Synapse, but I did not find documentation nor download to use with the Lazarus.

I made one post in the topic of conversion of the Delphi/kylix for the Lazarus, therefore I cited urlmon

it wanted a conversion of urlmon

tks, I go see link
TinyPortal © 2005-2018