Download a file without external libraries lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- torbente · 2018-05-28 07:42 I was checking how to download a file from internet and even when it is easy with Synapse, i want to know if it is possible without add a new library, only with the ones installed in lazarus v1.8.2 by default. My app need check if windwos is 32/64 bit, and donwload the necessary SSL files automatically (i plan to use this link for that: http://wiki.lazarus.freepascal.org/Detect_Windows_x32-x64_example ) ---------------------------------------------------------------------- Thaddy · 2018-05-28 08:45 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // untested, but should workfunction IsWin64:Boolean;begin   Result := false;   {$if defined(win64)}Result := true;{$ifend}end; ---------------------------------------------------------------------- torbente · 2018-05-28 09:12 Quote from: Thaddy on May 28, 2018, 10:45:57 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // untested, but should workfunction IsWin64:Boolean;begin   Result := false;   {$if defined(win64)}Result := true;{$ifend}end; Works perfect and very simple!! ---------------------------------------------------------------------- marcov · 2018-05-28 09:24 Such function checks if the binary is 64-bit, not if windows is 64-bit. ---------------------------------------------------------------------- Thaddy · 2018-05-28 09:31 Quote from: marcov on May 28, 2018, 11:24:59 amSuch function checks if the binary is 64-bit, not if windows is 64-bit. I interpreted the question as for which platform are we compiling? In his case that can be a 32 bit windows or a 64 bit windows. My solution provides for that. (IOW a 64 bit compiler for a 64 bit Windows needs 64 bit libraries. A 32 bit compiler will download the 32 bit libraries even on a 64 bit windows) My understanding is that is what he means. To be more precise it detects the target binaries, which he needs to download and install the target libraries. But you know that. ---------------------------------------------------------------------- rvk · 2018-05-28 09:36 Yes, my understanding is also that you need to know what bitness your program is. That's needed to download the correct OpenSSL files. You can't have 64bit OpenSSL with 32 bit program, even if your Windows is 64 bit. So you might want to use this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses fphttpclient, zipper; type  TMyUnZipper = class(TUnZipper)    FMyStream: TStream;  private    procedure MyStreamOpen(Sender: TObject; var AStream: TStream);  public    constructor Create(AStream: TStream);  end; constructor TMyUnZipper.Create(AStream: TStream);begin  inherited Create;  FMyStream := AStream;  OnOpenInputStream := @MyStreamOpen;end; procedure TMyUnZipper.MyStreamOpen(Sender: TObject; var AStream: TStream);begin  AStream := FMyStream;end; procedure DownloadOpenSSL;var  Url: string;  UnZipper: TUnZipper;  Stream: TStream;  List: TStringList;begin  if not FileExists('ssleay32.dll') then  begin  {$IFDEF WIN32}    Url := 'http://indy.fulgan.com/SSL/openssl-1.0.2h-i386-win32.zip';  {$ELSE}  Url := 'http://indy.fulgan.com/SSL/openssl-1.0.2h-x64_86-win64.zip';  {$ENDIF}    Stream := TMemoryStream.Create;    TFPCustomHTTPClient.SimpleGet(Url, Stream); // get the .zip    UnZipper := TMyUnZipper.Create(Stream); // NOTE. UnZipper will release the Stream !!    try      List := TStringList.Create;      List.Add('ssleay32.dll');      List.Add('libeay32.dll');      UnZipper.UnZipFiles(List);    finally      UnZipper.Free;      List.Free;    end;  end;end;