unit u_FormAufruf;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TSecSigner_AssignDocuments =
function( inArrDocs :
Array of PChar;
inIDocCount : Integer)
: Integer;
cdecl;
type
TFormMain =
class(TForm)
Button1: TButton;
reDisplay: TRichEdit;
edDllName: TEdit;
edDllFunktion: TEdit;
lbDllName: TLabel;
lbDllFunktion: TLabel;
procedure Button1Click(Sender: TObject);
private
fLibHandle: THandle;
SecSigner_AssignDocuments : TSecSigner_AssignDocuments;
function loadSecSignerLibrary: Boolean;
public
{ Public-Deklarationen }
end;
var
FormMain: TFormMain;
implementation
{$R *.dfm}
procedure TFormMain.Button1Click(Sender: TObject);
var
lArrDocs :
Array of PChar;
lICount,
lIResult,
I: Integer;
begin
SetLength(lArrDocs, 4);
lArrDocs[0] := '
test1';
lArrDocs[1] := '
test2';
lArrDocs[2] := '
test3';
lArrDocs[3] := '
test4';
if loadSecSignerLibrary
then
try
if Assigned(SecSigner_AssignDocuments)
then
begin
lICount := Length(lArrDocs);
for I := 0
to Length(lArrDocs) - 1
do
begin
reDisplay.Lines.Add('
-'+lArrDocs[i]);
end;
reDisplay.Lines.Add('
Übergabe Count: '+IntToStr(lICount));
lIResult := SecSigner_AssignDocuments(lArrDocs, lICount);
//Hier Hat lICount den Wert 4
reDisplay.Lines.Add('
Result: '+IntToStr(lIResult));
end else
reDisplay.Lines.Add('
Funktion nicht gefunden');
finally
freeLibrary(fLibHandle);
end;
end;
function TFormMain.loadSecSignerLibrary: Boolean;
begin
Result := true;
try
fLibHandle := loadLibrary(PChar(edDllName.text));
if fLibHandle <> 0
then
begin
@SecSigner_AssignDocuments := getProcAddress(fLibHandle, PChar(edDllFunktion.Text));
reDisplay.Lines.Add('
getProcAddress erfolgreich');
end else
begin
Result := false;
reDisplay.Lines.Add('
DLL nicht gefunden');
end;
except
Result := false;
end;
end;
end.