Recent

Author Topic: [SOLVED]Who can really provide the right code...  (Read 17426 times)

Robert W.B.

  • Sr. Member
  • ****
  • Posts: 331
  • Love my Wife, My Kids and Lazarus/Freepascal.
[SOLVED]Who can really provide the right code...
« on: October 08, 2012, 11:41:30 pm »
to make lazarus work like Delphi. I use URLmon with Delphi to get an Url in text but,in Lazarus it don't work and not with synapse or curl!
Is there a way for Lazarus to use URLmon from Delphi?

This is the only way that keeps me to still use Delphi and not Lazarus as a professional Developtools.

Synapse and CUrl!I have give up on these unsupported libraries.

Have anyone the knowledge?  :'(  :'(  :'(
« Last Edit: February 12, 2013, 01:28:37 am by robbanux »
Rob

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Who can really provide the right code...
« Reply #1 on: October 09, 2012, 03:03:37 am »
Could you provide a sourcecode from simple test program that fails? Someone might be able to point out if there is mistakes.

Also as far as i know, Synapse is still being actively developed. There is SVN version of it same way as Lazarus and freepascal.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Who can really provide the right code...
« Reply #2 on: October 09, 2012, 05:07:53 am »
Quote
Synapse and CUrl!I have give up on these unsupported libraries.
Synapse IS supported and actively developed, have you ever even asked about it at least here or directly to the author?

Robert W.B.

  • Sr. Member
  • ****
  • Posts: 331
  • Love my Wife, My Kids and Lazarus/Freepascal.
Re: Who can really provide the right code...
« Reply #3 on: October 10, 2012, 10:40:15 pm »
I tried to mail the author but,the mail-account of his, is not working! Maybe he dont want any mail!  :(
Rob

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Who can really provide the right code...
« Reply #4 on: October 11, 2012, 12:08:18 am »
You can always ask here what you would have asked of him.

Is there a problem setting up SVN version of Synapse, or still a problem with specific code? We cannot help without information.

Laksen

  • Hero Member
  • *****
  • Posts: 802
    • J-Software
Re: Who can really provide the right code...
« Reply #5 on: October 11, 2012, 01:14:45 am »
The following works great for me. Your question was a little vague though. A mistake often made when working with Synapse is trying to access HTTPS pages without having added an SSL unit. For that you can use for example the ssl_openssl unit(requires openssl libraries installed)
Code: [Select]
uses classes, httpsend;

function DownloadUrl(const AUrl: string): string;
var ss: TStringStream;
begin
   ss := TStringStream.Create('');
   try
      if HttpGetBinary(AUrl, ss) then
      begin
         ss.Seek(0, soBeginning);
         result := ss.DataString;
      end
      else
         result := 'Failed to download URL';
   finally
      ss.Free;
   end;
end;

Robert W.B.

  • Sr. Member
  • ****
  • Posts: 331
  • Love my Wife, My Kids and Lazarus/Freepascal.
Re: Who can really provide the right code...
« Reply #6 on: October 11, 2012, 02:33:09 am »
Thanks for the code but,how do You call the URL with DownloadURL?

 I use this link and it wont work!I think it has something to do that the company change the Url from Http to Https

if HttpGetURL('myurl','mytextfile.txt')=True then begin

some code...

end;

and the function

function HttpGetFile(const URL: String; const FileName: String): Boolean;
var
  Stream: TFileStream;
begin
  Stream := TFileStream.Create(FileName, fmCreate);
  try
    Result := HttpGetBinary(URL, Stream);
  finally
    Stream.Free;
  end;
end;

and it dosent work now but it has worked before the company switchfrom Http to Https         
Rob

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Who can really provide the right code...
« Reply #7 on: October 11, 2012, 02:43:35 am »
You can test by inserting the same url directly to webbrowser, and see if it can open it either. Preferrably use browser where you don't have previous cache or possible saved passwords about it.

Robert W.B.

  • Sr. Member
  • ****
  • Posts: 331
  • Love my Wife, My Kids and Lazarus/Freepascal.
Re: Who can really provide the right code...
« Reply #8 on: October 11, 2012, 02:50:08 am »
The URL I use are open fine in the browser but, it don,t work with synapse!

Can You provide me with the right code for downloading an URL with the function I've got!

There was to missing end; in the code but they are there now.

Uses http;
function DownloadUrl(const AUrl: string): string;
var ss: TStringStream;
begin
   ss := TStringStream.Create('');
   try
      if HttpGetBinary(AUrl, ss) then
      begin
         ss.Seek(0, soBeginning);
         result := ss.DataString;
      end
      else
         result := 'Failed to download URL';
   finally
      ss.Free;
end; 

and the URl should be?

DownloadUrl code code

 :'(
               
Rob

Laksen

  • Hero Member
  • *****
  • Posts: 802
    • J-Software
Re: Who can really provide the right code...
« Reply #9 on: October 11, 2012, 02:57:09 am »
You have to add an SSL driver. HTTPS is not handled by default in Synapse.

One such driver is openssl. To use that:
Add ssl_openssl to your uses list, and install the openssl library. That should fix it

Robert W.B.

  • Sr. Member
  • ****
  • Posts: 331
  • Love my Wife, My Kids and Lazarus/Freepascal.
Re: Who can really provide the right code...
« Reply #10 on: October 11, 2012, 03:06:36 am »
I added ssl_openssl to my uses list but,it dont work! I cant get the url!
Same problem.
 Is there more code I shall provide in my function?   :'(
Rob

Laksen

  • Hero Member
  • *****
  • Posts: 802
    • J-Software
Re: Who can really provide the right code...
« Reply #11 on: October 11, 2012, 03:21:44 am »
Did you also install openssl? http://www.openssl.org/

Robert W.B.

  • Sr. Member
  • ****
  • Posts: 331
  • Love my Wife, My Kids and Lazarus/Freepascal.
Re: Who can really provide the right code...
« Reply #12 on: October 11, 2012, 03:26:45 am »
Sorry but, I use Windows 7 64 bit today and not Linux.
Are there now Windows file to download?
Rob

Laksen

  • Hero Member
  • *****
  • Posts: 802
    • J-Software
Re: Who can really provide the right code...
« Reply #13 on: October 11, 2012, 03:34:27 am »
Yes. A simple search returns this, where I also got it from: http://slproweb.com/products/Win32OpenSSL.html

Timewarp

  • Full Member
  • ***
  • Posts: 144
Re: Who can really provide the right code...
« Reply #14 on: October 11, 2012, 08:48:39 am »
I'm using urlmon and I don't have problems with it, works just like in Delphi.

Problem is missing urlmon.pas on something else? Show the Delphi code

 

TinyPortal © 2005-2018