江
江远
Unregistered / Unconfirmed
GUEST, unregistred user!
[?][?]使用时会报内存操作错误!<br>请高手帮助看一看如何解决.<br><br>1. DLL的生成程序<br>library Project1;<br>uses<br> SysUtils, Classes;<br>{$R *.res}<br>procedure SetString(StrAddr:Integer);stdcall;<br>begin<br> PString(StrAddr)^ := '123ABC';<br>end;<br>exports<br> SetString;<br>begin<br>end.<br><br>2. 调用程序(部分)<br>.....<br>procedure SetString(Addr:integer);stdcall;external 'Project1.dll';<br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> public<br> end;<br>var<br> Form1: TForm1;<br>implementation<br>{$R *.dfm}<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> sTmp : string;<br> iAddr : Integer;<br>begin<br> iAddr := Integer(@sTmp);<br> SetString(iAddr);<br> ShowMessage(sTmp);<br>end;