没治了,我把我测试dll的程序贴上来<br><br>unit main;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> f = function(x,y:integer):integer;stdcall;<br> TForm1 = class(TForm)<br> Edit1: TEdit;<br> Edit2: TEdit;<br> Edit3: TEdit;<br> Button1: TButton;<br> Edit5: TEdit;<br> Edit4: TEdit;<br> Button2: TButton;<br> OpenDialog1: TOpenDialog;<br> procedure Button1Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> h: Hwnd;<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> fn:string;<br> f1:f;<br> x,y,z:integer;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> x:=strtoint(edit1.Text);<br> y:=strtoint(edit2.Text);<br> f1:=nil;<br> h:=loadlibrary(pchar(fn));<br> if h<>0 then<br> begin<br> showmessage('成功挂上!');<br> @f1:=GetProcAddress(h,PChar(edit5.Text));<br> end else<br> begin<br> messagebox(handle,'文件未找到!','NOTICE',MB_OK);<br> exit;<br> end;<br> if assigned(f1) then<br> begin<br> z:=f1(x,y);<br> edit3.Text:=inttostr(z);<br> end;<br> freelibrary(h);<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br> if opendialog1.Execute then<br> fn:=opendialog1.FileName;<br> edit4.Text:=fn;<br>end;<br><br>end.