经典的例子:
Dll工程文件:
library DllPj;
uses
SysUtils,
Classes;
{$R *.RES}
function Plusnum(X,Y:Integer):Integer;stdcall;
begin
Result:=X+Y;
end;
exports
Plusnum index 1;
begin
end.
测试用的工程文件:
unit dllUnit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
function Plusnum(X,Y:integer):integer;stdcall;external 'DllPj.dll';
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(Inttostr(Plusnum(Strtoint(Edit1.text),strtoint(Edit2.text))));
end;
end.