type
TAboutHW=function(AppName :String):integer;Stdcall;// dll的声明
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
aHandle :THandle;
AboutSh :TAboutHW;
begin
aHandle :=LoadLibrary('zAbout.dll');
try
if aHandle<>0 then
begin
@aboutsh:=GetProcAddress(aHandle,'AboutShow');
Caption :=InttoStr(Aboutsh(application.ExeName));
end;
finally
freeLibrary(aHandle);
end;
end;
end.
{ 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
zAboutFrm in 'zAboutFrm.pas' {zAboutForm};
exports
AboutShow;
begin
end.
////////////////////{ zAboutFrm.pas,this form 选不自动创建窗体!!! }////////////
{ show form }
unit zAboutFrm;
{显示内容}
Procedure GetMyInfo(IfType:TIfType;Var Info :TStringList);
Procedure SetPrcIf(Var Info:TStringList);
Procedure GetOSIf(Var Info:TStringList);
} public
end;
function AboutShow(AppName:String):integer;Stdcall
//必须通过函数创建form实例!!!
implementation
{$R *.DFM}
function AboutShow(AppName:String):integer;
var
zAboutForm :TzAboutForm;
begin
result :=-1;
zAboutForm :=TzAboutForm.Create(Application);
try
with zAboutForm do
begin
ShowModal;
result :=0;
end;
finally
zAboutForm.Free;
end;
end;