显式例子:
ユニットメイン;
インタフェース
用途
窓、メッセージ、sysutils、バリアント、クラス、グラフィック、コントロール、フォーム、
ダイアログ、stdctrls、extctrls、グリッド、dbgrids、db、dbtables、dbctrls;
タイプ
tform1 = class(tform)
Button1:Tbutton;
編集1:tedit;
edit2:tedit;
Image1:タイム;
DataSource1:tdatasource;
表1:ttable;
table1speciesno:tfloatfield;
Table1Category:Tstringfield;
Table1common_name:Tstringfield;
Table1SpeciesName:TStringfield;
table1lengthcm:tfloatfield;
table1length_in:tfloatfield;
Table1notes:tmemofield;
Table1graphic:tgraphicfield;
dbgrid1:tdbgrid;
手順button1click(sender:tobject);
プライベート
{プライベート宣言}
公共
{公開宣言}
終わり;
// function getinteger(i:integer):integer; stdcall; external 'dllone.dll';
//関数getDouble(f:double):double; stdcall; external 'dllone.dll';
tgetDouble = function(f:double):double; stdcall;
var
form1:tform1;
実装
{$ r *.dfm}
手順tform1.button1click(sender:tobject);
var D:double;
dllhandle:thandle;
FUNC:TgetDouble;
始める
image1.picture.Assign(table1graphic);
table1graphic.Assign(image1.picture);
出口;
dllhandle:= loadlibrary( 'dllone.dll');
試す
@func:= getProcAddress(dllhandle、 'getDouble');
//edit1.text:= inttostr(getinteger(2));
// d:= getDouble(2.2);
割り当てられている場合(@func)
始める
d:= func(2.2);
edit2.text:= floattostr(d);
終わり;
ついに
FreeLibrary(dllhandle);
終わり;
終わり;
終わり。
隐式例子:
ライブラリdllone;
用途
sysutils、
クラス;
{$ r *.res}
関数getDoubleExt(f:double):double; stdcall; external 'dlltwo.dll';
function getint(i:integer):integer; stdcall; external 'dlltwo.dll';
関数getInteger(i:integer):integer; stdcall;
始める
結果:= getInt(i);
終わり;
関数GetDouble(D:double):double; stdcall;
始める
結果:= getDoubleExt(d);
終わり;
輸出
getinteger、
GetDouble;
始める
終わり。
図書館dlltwo;
{dllメモリ管理に関する重要な注意:sharememは
ライブラリの使用節とプロジェクトの最初のユニット(選択
Project-View Source)DLLが手順をエクスポートする場合、または
文字列をパラメーターまたは関数の結果として渡す関数。これ
DLLに出入りするすべての文字列に適用されます。
記録とクラスにネストされています。 Sharememはインターフェイスユニットです
borlndmm.dll共有メモリマネージャー。
DLLで。 borlndmm.dllの使用を避けるには、文字列情報を渡します
PCHARまたは略語パラメーターを使用します。 }
用途
sysutils、
クラス;
{$ r *.res}
関数getDoubleExt(D:double):double; stdcall;
始める
結果:= d;
終わり;
function getint(i:integer):integer; stdcall;
始める
結果:= i;
終わり;
輸出
getDoubleExt、
getint;
始める
終わり。