Hay dos formas de llamar o usar rutinas que estan contenidas en una dll, y usar estas en tu proyecto delphi.
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons;
type
TfrmMain = class(TForm)
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
public
end;
Function Suma(a,b:Single):single; External 'Suma.Dll';
var
frmMain: TfrmMain;
implementation
{$R *.DFM}
procedure TfrmMain.BitBtn1Click(Sender: TObject);
Var
a,b,c:Single;
begin
a:=10.0; b:=2.0;c:=0;
c:=Suma(a,b);
end;
procedure TfrmMain.BitBtn2Click(Sender: TObject);
type
TSuma = Function(a,b:Single); stdcall;
var
DLLHandle: THandle;
Suma: TSuma;
a,b,c:Single;
begin
DLLHandle := LoadLibrary('SUMA.DLL');
try
if DLLHandle <= 0 then
ShowMessage('Error Dll no encontrada...');
@Suma := GetProcAddress(DLLHandle, 'Suma');
if Assigned(Suma) then
begin
a:=10.0; b:=2.0;c:=0;
c:=Suma(a,b);
end
else
ShowMessage('Procedimiento/Funcion no encontrado');
finally
Application.ProcessMessages;
FreeLibrary(DLLHandle);
end;
end;
end.
La Dll debe estar junto con tu ejecutable o en una ruta que pueda ser ubicada como por ejemplo x:\windows\system32
Saludos