Como usar uma DLL
Olá bom dia!
Estou efetuando uns testes então criei uma dll, compilei, e salvei dentro de uma pasta chamada desenvolvimento :
library dll;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library´s USES clause AND your project´s (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes;
function Max(a, b : double):double; Export;
begin
result:= a + b;
end;
exports
Max;
begin
end.
Logo após crei uma nova aplicacão para chamar essa função, e tambem salvei dentro da mesma pasta desenvolvimento :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, WinProcs, WinTypes;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
Function max(a,b : double):double; External ´dll.dll´;
{$R *.DFM}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
teste: double;
begin
teste:=max(10,5);
showmessage(´ok´);
end;
end.
Quando mando executar o programa está me retornando o seguinte erro
Não foi possivel localizae o ponto de entrada do procedimento max na biblioteca de vínculo dinâmico dll.dll .
Alguém sabe como posso resolver isso?
Obrigado
Estou efetuando uns testes então criei uma dll, compilei, e salvei dentro de uma pasta chamada desenvolvimento :
library dll;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library´s USES clause AND your project´s (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes;
function Max(a, b : double):double; Export;
begin
result:= a + b;
end;
exports
Max;
begin
end.
Logo após crei uma nova aplicacão para chamar essa função, e tambem salvei dentro da mesma pasta desenvolvimento :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, WinProcs, WinTypes;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
Function max(a,b : double):double; External ´dll.dll´;
{$R *.DFM}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
teste: double;
begin
teste:=max(10,5);
showmessage(´ok´);
end;
end.
Quando mando executar o programa está me retornando o seguinte erro
Não foi possivel localizae o ponto de entrada do procedimento max na biblioteca de vínculo dinâmico dll.dll .
Alguém sabe como posso resolver isso?
Obrigado
Anonymous
Curtidas 0