unit UnitDLL_Laden;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type TSummenFunktion =
function(zahl1, zahl2: integer): integer;
stdcall;
type
TForm1 =
class(TForm)
BtnLade_Neu: TButton;
edtErgebnis: TEdit;
BtnRechne: TButton;
OpenDialog_DLL_Org: TOpenDialog;
BtnOeffnen_Org_Org: TButton;
BtnOeffnen_Neu: TButton;
OpenDialog_DLL_Neu: TOpenDialog;
BtnLade_Org: TButton;
Update_Timer: TTimer;
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
LibHandle: THandle;
public
{ Public-Deklarationen }
end;
{---------------------------------------------------------------------------}
var
Form1: TForm1;
{---------------------------------------------------------------------------}
implementation
{---------------------------------------------------------------------------}
{$R *.dfm}
{---------------------------------------------------------------------------}
procedure TForm1.FormCreate(Sender: TObject);
var
SummenFunktion : TSummenFunktion;
DLL_Name :
String;
begin
DLL_Name := '
DLL_Projekt.dll';
LibHandle := LoadLibrary(PChar(DLL_Name));
if Handle <> 0
then
begin
@SummenFunktion := GetProcAddress(
Handle, '
addiere');
if @SummenFunktion <>
nil then
begin
edtErgebnis.Text := IntToStr(SummenFunktion(10, 20));
end;
end;
end;
{---------------------------------------------------------------------------}
procedure TForm1.FormDestroy(Sender: TObject);
begin
FreeLibrary(LibHandle);
// Free Memory Allocated for the DLL
end;
{---------------------------------------------------------------------------}
end.