6
6713827
Unregistered / Unconfirmed
GUEST, unregistred user!
公共部分<br>[red]TWMSOCK = procedure(ToAdd:TSockAddrIn;var ABuffer;Count:Integer) of [/red]<br>dll部分!<br>[red]procedure TUDP.WMSOCKET(var Message: TMessage);<br>var<br> addr: TSockAddrIn;<br> addrlen: Integer;<br> buffer: array [0..20480] of byte;<br>begin<br> case WSAGetSelectEvent(Message.LParam) of<br> FD_READ:<br> begin<br> addrlen:=sizeof(addr);<br> addrlen:=recvfrom(sock,buffer,20480,0,addr,addrlen);<br> WMSOCK(Addr,Buffer,Addrlen);<br> buffer:=buffer;<br> End;<br> End;<br>End;[/red]<br>exe部分<br>[red]Function UDPSend(ToAdd:TSockAddrIn;Var Buffer;Count:Integer):Integer;<br> stdcall; external 'WinSocketUDP.dll';<br>procedure TForm1.WMSOCK(ToAdd:TSockAddrIn;var ABuffer;Count:Integer);<br>Var A: PChar;<br> B: String;<br>begin<br> Try<br> getmem(A,Count);<br> //move(ABuffer,a,Count);<br> //Showmessage(Inttostr(sizeof(toadd)));<br> Move(ABuffer,b,Count-1);<br> Memo1.Lines.Add('包长度:'+Inttostr(Count)+':'+b);<br> Form1.Caption:=Inttostr(Strtoint(Form1.Caption)+1);<br> except<br> End;<br>end;[/red]<br>当调用过程时,提示【存取地址00403E46为例发生在模块'exe.exe'种.读地址00000000里.】<br>有那位大侠知道怎么处理啊!