Recent

Author Topic: urlmon for lazarus - convert possible?  (Read 10471 times)

Onjahyr-BR

  • Full Member
  • ***
  • Posts: 121
urlmon for lazarus - convert possible?
« 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

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2582
RE: urlmon for lazarus - convert possible?
« Reply #1 on: September 26, 2006, 10:46:12 am »
It might be possible if you know what unit they used for:
  internetopen, internetopenurl, internetreadfile, internetclosehandle
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

CCRDude

  • Hero Member
  • *****
  • Posts: 596
RE: urlmon for lazarus - convert possible?
« Reply #2 on: September 26, 2006, 11:09:11 am »
Here 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.

Onjahyr-BR

  • Full Member
  • ***
  • Posts: 121
RE: urlmon for lazarus - convert possible?
« Reply #3 on: September 26, 2006, 01:06:00 pm »
it forgives, using the Linux

CCRDude

  • Hero Member
  • *****
  • Posts: 596
RE: urlmon for lazarus - convert possible?
« Reply #4 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 from unit httpsend.

Onjahyr-BR

  • Full Member
  • ***
  • Posts: 121
urlmon for lazarus - convert possible?
« Reply #5 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