Load SSL DLL - Delphi

0

I'm having trouble downloading files with https: // protocol. Looking for information, I was informed that I should load the DLLs. I found people showing "how it loads", but since I never performed this procedure, I'm having a lot of trouble.

Before I tried to add the indy component, but I got errors, so this is my "last solution":

uses: IdHTTP, IdSSLOpenSSL;

IdHTTP1 := TIdHTTP.create(nil);
 try
            IdHTTP1.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);  
            IdHTTP1.Request.Accept := 'text/html, */*';
            IdHTTP1.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0';
            IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
            IdHTTP1.HandleRedirects := True;
            IdHTTP1.get(FNomeArq,MS);
            Ms.Seek(0,soFromBeginning);
            header := IdHTTP1.Response.ContentType;
 except on E : EIdHTTPProtocolException do begin
             showmessage(intToStr(IdHTTP1.ResponseCode));
            end;
            on E: EIdSocketError do begin
                showmessage(intToStr(IdHTTP1.ResponseCode));
            end;
            on E: Exception do begin
              showmessage(intToStr(IdHTTP1.ResponseCode));
            end;
 end;
  

I made an application that uses the openssl DLLs (libeay32.dll and   ssleay32.dll). It's indy to use them, I do not call the DLLs directly.

     

The simplest solution I found to avoid an installer (i   just delpoy an exe and I'm ok with this approach) is:

     

put the DLLs as exe features at the beginning of the program that I   extract them in the exe folder the exe uses them

I downloaded the DLLs here:

link

I took some examples on the internet, but I did not get any success:

procedure TForm1.Button2Click(Sender: TObject);

type

  // vamos declarar um tipo function
  TSomarFuncao = function(a, b: Integer): Integer; stdcall;
var
  Somar: TSomarFuncao; // uma variável que representará a função
  DLLHandle: THandle; // este é o handle para a DLL
begin
  // vamos carregar a DLL
  DLLHandle := LoadLibrary('\dll\libeay32.dll');
  DLLHandle := LoadLibrary('\dll\ssleay32.dll');
  try
    // vamos obter o endereço da função na DLL
    Somar := GetProcAddress(DLLHandle, 'Somar');

    // vamos chamar a função agora
    if Assigned(Somar) then
      ShowMessage(IntToStr(Somar(4, 3)))
    else
      ShowMessage('Não foi possível chamar a rotina desejada');
  finally
    FreeLibrary(DLLHandle); // vamos liberar a DLL
  end;

end;

How do I load these DLLs into my application?

    
asked by anonymous 13.08.2015 / 02:20

0 answers