I
iovy
Unregistered / Unconfirmed
GUEST, unregistred user!
-----------C中dll头文件 <br>bool WINAPI AddExistComPort(BYTE byComPort = 1,<br> DWORD dwBaudRate = 9600,<br> BYTE byParity = 0,<br> BYTE byStopBits = 1,<br> BYTE byByteSize = 8,<br> LPONDEBUGRCV lpDebugRcv = NULL,<br> LPONRESPANDMORCV lpMoOrRespRcv = NULL,<br> unsigned int uMsgFormat = 0);<br><br>#define DEBUGPARA char szComPort[7],char szDebugMsg[1024]<br>#define RCVMOANDRESTPARA char szComPort[7],char szATCmdForRcvOrResp[1024]<br><br>typedef int (*LPONDEBUGRCV)(const char * szComPort,const char * szDebugMsg);<br>typedef int (*LPONRESPANDMORCV)(const char * szComPort,const char* szATCmdForRcvOrResp);<br><br>---------我在delpih中调用程序<br><br>type<br> rszATCmdForRcvOrResp = array[0..1024]of char;<br> <br> TszComPort = array[0..7]of char;<br> TszDebugMsg = array[0..1024]of char;<br> TLPONDEBUGRCV = function(szComPort : TszComPort ;szDebugMsg : TszDebugMsg):integer;stdcall;<br> TLPONRESPANDMORCV = function(szComPort : TszComPort ; szATCmdForRcvOrResp : rszATCmdForRcvOrResp):integer;stdcall;<br> function AddExistComPort(byComPort:Cardinal; //端口号<br> dwBaudRate: Cardinal;//频率<br> byParity:Cardinal;<br> byStopBits:Cardinal;<br> bybyteSize:Cardinal;<br> lpDebugRcv:TLPONDEBUGRCV;//回调函数,调试信息<br> lpMoOrRespRcv:TLPONRESPANDMORCV;//接收以及回应回调函数<br> uMsgFormat:Cardinal<br> ):boolean; stdcall;<br><br>function lpDebugRcv(szComPort : TszComPort ;szDebugMsg : TszDebugMsg):integer;stdcall;<br>function lpMoOrRespRcv(szComPort : TszComPort ; szATCmdForRcvOrResp : rszATCmdForRcvOrResp):integer;stdcall;<br>implementation<br> //打开串口<br> function AddExistComPort ; external ATComDllLIB name 'AddExistComPort';<br>function lpDebugRcv(szComPort : TszComPort ;szDebugMsg : TszDebugMsg):integer;stdcall;<br>begin<br> form1.Memo1.Lines.Add(szComPort);<br> result := 1;<br>end;<br><br>function lpMoOrRespRcv(szComPort : TszComPort ; szATCmdForRcvOrResp : rszATCmdForRcvOrResp):integer;stdcall;<br>begin<br> form1.Memo1.Lines.Add(szComPort);<br> result := 1;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> AddExistComPort(1,9600,0,1,8,lpDebugRcv,lpMoOrRespRcv,0);<br>end;<br><br>end.<br><br><br>在调用dll中函数的时候没有出现问题.而回调函数的时候,报内存错误.请兄弟给给意见,谢谢