library templete;{ Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL--even those that are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. }uses ShareMem, SysUtils, windows, Classes, test in 'test.pas' {frmTest}, Date1 in 'Date1.pas' {frmDate1}, Pub in 'Pub.pas', Date2 in 'Date2.pas' {frmDate2};{$R *.res} {$E plg.}function test(HICON :Hicon) : Boolean; stdcall; var frm : TFrmTest; begin Result := False; IconHandle := HICON; frm := TFrmTest.Create(nil); try frm.Icon.Handle := HICON; frm.Go; finally frm.Free; end; result := true; end;function GetDate1(var Date1 : TDateTime) : Boolean; stdcall; var frmDate1 : TfrmDate1; begin Result := False; try frmDate1 := TfrmDate1.Create(nil); frmDate1.ShowModal; finally frmDate1.Free; end; Date1 := Pub.Date1; Result := True; end;function GetDate2(var Date1 : TDateTime; var Date2 : TDateTime) : Boolean; stdcall; var frmDate2 : TfrmDate2; begin Result := False; try frmDate2 := TfrmDate2.Create(nil); frmDate2.ShowModal; finally frmDate2.Free; end; Date1 := Pub.Date1; Date2 := Pub.Date2; Result := True; end; exports test, GetDate1, GetDate2; beginend. 这个是我写的一个插件,呵呵,DLL基本上就是这个样子。
[email protected]
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }uses
ShareMem,
SysUtils,
windows,
Classes,
test in 'test.pas' {frmTest},
Date1 in 'Date1.pas' {frmDate1},
Pub in 'Pub.pas',
Date2 in 'Date2.pas' {frmDate2};{$R *.res}
{$E plg.}function test(HICON :Hicon) : Boolean; stdcall;
var frm : TFrmTest;
begin
Result := False;
IconHandle := HICON;
frm := TFrmTest.Create(nil);
try
frm.Icon.Handle := HICON;
frm.Go;
finally
frm.Free;
end;
result := true;
end;function GetDate1(var Date1 : TDateTime) : Boolean; stdcall;
var frmDate1 : TfrmDate1;
begin
Result := False;
try
frmDate1 := TfrmDate1.Create(nil);
frmDate1.ShowModal;
finally
frmDate1.Free;
end;
Date1 := Pub.Date1;
Result := True;
end;function GetDate2(var Date1 : TDateTime; var Date2 : TDateTime) : Boolean; stdcall;
var frmDate2 : TfrmDate2;
begin
Result := False;
try
frmDate2 := TfrmDate2.Create(nil);
frmDate2.ShowModal;
finally
frmDate2.Free;
end;
Date1 := Pub.Date1;
Date2 := Pub.Date2;
Result := True;
end;
exports
test,
GetDate1,
GetDate2;
beginend.
这个是我写的一个插件,呵呵,DLL基本上就是这个样子。
唯一的区别就是需要动态创建窗体。
exprots是导出的过程,过程要用stdcall