dll问题,为什么写个简单的例子也会出错? ( 积分: 20 )

  • 主题发起人 主题发起人 hawii
  • 开始时间 开始时间
H

hawii

Unregistered / Unconfirmed
GUEST, unregistred user!
为什么写个简单的例子也会出错?<br>运行就出‘Access&nbsp;violation&nbsp;at&nbsp;address&nbsp;003820A1&nbsp;in&nbsp;module&nbsp;'MyDll.dll'’.&nbsp;Read&nbsp;of&nbsp;address&nbsp;00000000&nbsp;的错阿?<br>达人们帮忙看看。<br><br>//Mydll.dpr文件内容<br>function&nbsp;mSwap(var&nbsp;a,b:Integer):&nbsp;integer;stdcall;export;<br>var<br>&nbsp;&nbsp;c:Integer;<br>begin<br>&nbsp;&nbsp;c:=a;a:=b;b:=a;<br>&nbsp;&nbsp;Result:=1;<br>end;<br>exports<br>&nbsp;&nbsp;mSwap;<br><br>//调用模块内容。<br>&nbsp;&nbsp;function&nbsp;mSwap(var&nbsp;a,b:Integer):Integer;external&nbsp;'MyDll.dll'<br><br>procedure&nbsp;TForm1.Button1Click(Sender:&nbsp;TObject);<br>var<br>&nbsp;&nbsp;a,b:Integer;<br>begin<br>&nbsp;&nbsp;a:=SpinEdit1.Value&nbsp;;<br>&nbsp;&nbsp;b:=SpinEdit2.Value&nbsp;;<br>&nbsp;&nbsp;mSwap(a,b);<br>&nbsp;&nbsp;SpinEdit1.Value&nbsp;:=a;<br>&nbsp;&nbsp;SpinEdit2.Value&nbsp;:=b;<br>end;
 
function&nbsp;mSwap(var&nbsp;a,b:Integer):Integer;stdcall;external&nbsp;'MyDll.dll'
 
function&nbsp;mSwap(var&nbsp;a,b:Integer):Integer;&nbsp;stdcall;&nbsp;external&nbsp;'MyDll.dll'--这儿也要加stdcall
 
不错,发分!
 
后退
顶部