源程序如下:
TSendData = function(Dest,Sour
Char;datatype:Smallint;s_sub,r_sub
Char;tlen:integer;text
Char;wait:integer;TradeSour,DistCode,MainTx,TermNo,OperNo,Id
Char):smallint;stdcall;//far;External 'mgbdll.dll';
TRecvData = function(Dest,Sour
Char;var datatype:Smallint;s_sub,r_sub
Char;var tlen:integer;text
char;wait:integer;DataNum,MainTx,ReturnNo
Char):smallint;stdcall;//far;External 'mgbdll.dll';
...
len:=10;
SendSub:=SendSub+1;
GetMem(GetTxt,4050);
GetMem(Num,20);
GetMem(MTx,20);
GetMem(RetNo,20);
GetMem(IpDest,20);
GetMem(IpSource,20);
GetMem(PSendSub,20);
GetMem(PRecvSub,20);
IpDest:='10.1.1.169';
IpSource:='10.1.1.180';
PSendSub:='TrainServer';
PRecvSub:=Pchar(IntToStr(SendSub));
DType:=0;
SendTxt:=SendTxt+'|^';
Handle:=LoadLibrary('mgbdll.dll');
if Handle <> 0 then
begin
@SendData:=GetProcAddress(Handle,'SendData');
if @SendData <> nil then
Ret:=SendData(IpDest,IpSource,DType,PSendSub,PRecvSub,len,Pchar(SendTxt),
6000,'M','11111',Pchar(CMainTx),'111',Pchar(CurrentOperCode),Pchar(CurrentCustNo));
//sleep(3000);
@RecvData:=GetProcAddress(Handle,'RecvData');
if @RecvData <> nil then
Ret:=RecvData((IpSource,IpDest,DType,PSendSub,PRecvSub,len,GetTxt,6000,Num,MTx,RetNo);
end;
FreeLibrary(Handle);
我敢肯定dll在执行到RecvData函数中下面两句时出错:
datatype = aMSG.datatype;
strcpy(s_sub, aMSG.s_sub);
Dll中函数:
short __stdcall RecvData(char *Dest,char *Sour,short datatype,
char *s_sub, char *r_sub, int tlen, unsigned char *text, int wait,
char * DataNum,char *MainTx,char *ReturnNo)
short __stdcall SendData(char *Dest,char *Sour,short datatype,
char *s_sub, char *r_sub, int tlen,
unsigned char *text, int wait,
char *TradeSour, char *DistCode, char *MainTx,
char *TermNo, char * OperNo, char * ID)