type
TForm1 =
class(TForm)
OpenDialog: TJvOpenDialog;
JvListBox1: TJvListBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
JvEdit1: TJvEdit;
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
// procedure DLLAufruf(Command: Integer);
procedure Button4Click(Sender: TObject);
private
Lib: THandle;
PluginGetName: TGetName;
PluginGetVersion: TGetVersion;
PluginSetCallBackProc: TSetCallBackProc;
PluginGetData: TGetData;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure DLLAufruf(Command: Integer);
begin
ShowMessage(Format('
Command von DLL: %d', [Command]));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if Opendialog.Execute
then begin
Lib := LoadLibrary(PChar(OpenDialog.FileName));
if Lib = 0
then
ShowMessage('
Plugin konnte nicht geladen werden!');
@PluginGetName := GetProcAddress(Lib, '
GetName');
Self.JvListBox1.Items.Add('
Name: ' + PluginGetName);
@PluginGetVersion := GetProcAddress(Lib, '
GetVersion');
Self.JvListBox1.Items.Add('
Version: ' + PluginGetVersion);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if Lib <> 0
then begin
@PluginSetCallBackProc := GetProcAddress(Lib, '
SetCallBackProc');
PluginSetCallBackProc(@DLLAufruf);
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
@PluginGetData := GetProcAddress(Lib, '
GetData');
PluginGetData(StrtoInt(Self.JvEdit1.Text));
end;
end.