D
dnewb
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了个简单的dll静态调用程序,运行时系统提示错:<br>library device1;<br>uses<br> ShareMem,<br> SysUtils,<br> dialogs,<br> Classes;<br><br>{$R *.res}<br><br>function my1proc(buf: string):String; stdcall;<br>var<br> mybuf: string;<br>begin<br> mybuf:=buf;<br> delete(mybuf,1,3);<br> Result:=mybuf;<br>end;<br><br>exports my1proc;<br><br>begin<br>end.<br>以上是DLL程序<br>下面是主程序<br>function my1proc(buf: string); string; stdcall; external 'dlltest.dll'<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> //在edit1中输入一串字符, 调用DLL中的函数,将字符串的前3个字符删除,返回结果串<br> label2.caption:=my1proc(edit1.Text);<br> edit1.Text:='';<br> //系统在此处提示错误:Invalid Pointer Operation.<br> end;<br><br>错误现象: 当字符串少于4个字符,即处理后返回空串,程序运行正常,<br> 当字符串多于4个字符,即处理后返回一个非空子串,程序报错:Invalid Pointer Operation<br><br>