A abcls Unregistered / Unconfirmed GUEST, unregistred user! 2007-10-09 #1 我对回调函数不熟,看了几个例子,但都还没搞懂,请各位高手帮忙.
D Dstorm Unregistered / Unconfirmed GUEST, unregistred user! 2007-10-09 #2 {-------------EXE---------------------}<br>var<br> Form1: TForm1;<br> procedure Sm(str : string) ;<br> function Run(xx : Integer) : Boolean; stdcall ;external 'Project2.dll';<br><br>implementation<br>{$R *.dfm}<br>procedure Sm(str : string) ;<br>begin<br> ShowMessage(str);<br>end;<br>procedure TForm1.btn1Click(Sender: TObject);<br>begin<br> Run(Integer(@Sm));<br>end;<br>{------------------------dll------------------------------}<br>type<br> Tcallb = procedure (str : string);<br>{$R *.res}<br>function Run(xx : Integer) : Boolean;stdcall;<br>begin<br> Tcallb(xx)('回调');<br>end;<br>exports<br> Run;
{-------------EXE---------------------}<br>var<br> Form1: TForm1;<br> procedure Sm(str : string) ;<br> function Run(xx : Integer) : Boolean; stdcall ;external 'Project2.dll';<br><br>implementation<br>{$R *.dfm}<br>procedure Sm(str : string) ;<br>begin<br> ShowMessage(str);<br>end;<br>procedure TForm1.btn1Click(Sender: TObject);<br>begin<br> Run(Integer(@Sm));<br>end;<br>{------------------------dll------------------------------}<br>type<br> Tcallb = procedure (str : string);<br>{$R *.res}<br>function Run(xx : Integer) : Boolean;stdcall;<br>begin<br> Tcallb(xx)('回调');<br>end;<br>exports<br> Run;
D Dstorm Unregistered / Unconfirmed GUEST, unregistred user! 2007-10-09 #3 忘了,要是类回调,请在原形声明时加上"of object",切记