F
followindy
Unregistered / Unconfirmed
GUEST, unregistred user!
我现在要定义VBDLL.dll的三个接口函数,<br>在VB中这样定义:<br>Private Declare Function xcom_connect Lib "vbdll.dll" () As Long<br>Private Declare Function xcom_send Lib "vbdll.dll" (ByVal pMessageId As String, ByVal pbuffer As String, <br> ByVal nSize As Long, Optional ByVal nUsingDataBase As Long = 0, Optional ByVal nSendType As Long = 0, <br> Optional ByVal nBlockorFunction As Long = 50, <br> Optional ByVal nUnsendSave As Long = 0) As Long<br>Private Declare Function xcom_recv Lib "vbdll.dll" (ByVal nChannelId As Long, ByVal pbuffer As String, <br> ByVal nSize As Long, ByVal pMessageId As String, nRecvLength As Long, nBlockorFunction As Long, <br> Optional ByVal nUnsendSave As Long = &HFFFFFFFF) As Long<br><br>结果VB程序中调用这三个函数一切正常。<br><br>我在Delphi中这样定义<br> Function xcom_connect: longInt; stdCall external 'vbdll.dll';<br> Function xcom_send(pMessageId, pbuffer: PChar; nSize: longInt; nUsingDataBase: longInt = 0;<br> nSendType: longInt = 0; nBlockorFunction: longInt = 50; nUnsendSave: longInt = 0): longInt; stdCall external 'vbdll.dll';<br> function XCOM_recv(nChannelId: longInt; pbuffer: PChar; nSize: longInt;<br> pMessageId: PChar; nRecvLength: longInt; nBlockorFunction: longInt;<br> nWaitTime: longInt = $HFFFFFFFF): longInt; stdCall external 'vbdll.dll';<br><br>在Delphi程序中,XCOM_Connect调用正常,但XCOM_Send和XCOM_RECV一直报异常。<br>我怀疑是参数类型问题,在Delpi中定义时把PChar换成String、widestring,结果还是异常。<br><br>请指教。<br><br>(另外XCOM_RECV函数中参数nWaitTime: longInt = $HFFFFFFFF定义有问题,请问<br>这个缺省值怎样写呢?是$用得不对吗 )<br><br><br>