type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; function dlltest(s1:pchar ):pchar;external 'dll.dll'; var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); begin ShowMessage(dlltest(pchar('bona.shen'))); end;
end.
dll实现部分:
dllimpl.pas
unit dllimpl;
interface function dlltest(s1:pchar):pchar; function second(s1:pchar):pchar; function third(s1:pchar):pchar; exports dlltest,second;//third 没有导出,目的是想通过修改Dll文件导出表来完成 implementation
function third(s1:pchar):pchar; begin result := pchar(string(s1)+' third function been called!'); end;
function second(s1:pchar):pchar; begin result := pchar(string(s1)+' secord function been called!'); end;
function dlltest(s1:pchar):pchar; begin result := pchar(string(s1)+'hello world!'); end;