K
kaga
Unregistered / Unconfirmed
GUEST, unregistred user!
有一个C写的动态连接库:test.dll<br>其中:<br>SendMsg(<br> const int nNeedReply,<br> const char *sDestTermID,<br> const char *sMsgContent,<br>char *sMsgID,<br>int *nErrorCode <br>);<br>//-------------------------------------------------------<br>说明:<br>输出参数:<br>sMsgID : if success ,message id is filled in nMsgID;<br>nErrorCode : if Fail,error code is filled in nErrorCode<br>返回值:<br>0--OK<br>1--FAIL<br>-------------------------------------------------<br>本人用delphi 调用该函数,在一个独立的单元中有如下声明:<br>//Unit uTest;<br>interface <br> uses<br> ....<br> //....<br><br>function SendMsg(<br> nNeedReply :integer;<br> sDestTermID Char;<br> sMsgContent : PChar;<br>sMsgID : PChar;<br>nErrorCode : Int):Integer;stdcall;external 'test.dll';<br>//------------------------------------------------------------<br>在实现程序单元<br>unit main;<br>uses <br> uTest,....<br>....<br>//<br>procedure TForm1.Button1Click(Sender:TObject);<br>var<br> nNeedReply : Integer;<br> sDestTermID : PChar;<br> sMsgContent : PChar;<br> sMsgID : PChar;<br> nErrorCode : Integer;<br> CodeList : TStrings;<br>begin<br> CodeList := TStringList.Create;<br> nNeedReply :=1;<br> sMsgContent := PChar('消息测试');<br> nErrorCode :=0;<br> For i:=0 to CodeList.Count-1 do<br> begin<br> sDestTermID := CodeList.Strings;<br> if SendMsg(nNeedReply,sDestTermID,sMsgContent,nErrorCode) = 0 then<br> memLog.lines.add('发送成功')<br> else<br> memLog.lines.add('发送失败');<br> sleep(30);<br>end;<br>end;<br>---------------------------------------<br>结果是这样的:<br>当我发送第一个号码时,能成功;再第二次循环时出现问题。<br>问题提示为:<br> 'Access violation at Ox00404197 : read of address Ox08631057 '<br><br>好象是由sMsgID 引起的,或者也有可能是nErrorCode引起的。<br>因为这2个是DLL的输出值。<br>由于本人功底比较浅薄,希望能得到各位朋友的帮助,帮我看看问题应该出现在什么地方,应如何解决比较好?<br>先谢谢了!