W weiwei81123 Unregistered / Unconfirmed GUEST, unregistred user! 2003-12-18 #23 PMSGData=^TMSGData TMSGData=Record Strlength:integer; Str:Array[0..0] of char; end; procedure TfrmClientMain.tbSendClick(Sender: TObject); var MSGDataMSGData; i,len:integer; SendStr:string; tmpPchar: pchar; begin SendStr:='<SMSMsg>13900239223$break$13916809666$break$天之道损有余而补不足,是故虚胜实,不足胜有余$break$-YYFA'; len:=length(SendStr); GetMem(MSGData, len+sizeof(integer)+1); try MSGData.Strlength:=len; tmpPchar := pchar(SendStr); for i := 0 to len-1 do begin MSGData.Str := tmpPchar; end; MSGData.Str[len] := #0; memo1.lines.add(inttostr(len)); memo1.lines.add(inttostr(sizeof(integer)+len)); Messagebox(0,pchar(MSGData.Str),'',MB_OK); ClientSocket.Socket.Sendbuf(MSGData,sizeof(integer)+len); finally FreeMem(MSGData); end; end; 顺便问一下,ghb1974的代码不行吗?
PMSGData=^TMSGData TMSGData=Record Strlength:integer; Str:Array[0..0] of char; end; procedure TfrmClientMain.tbSendClick(Sender: TObject); var MSGDataMSGData; i,len:integer; SendStr:string; tmpPchar: pchar; begin SendStr:='<SMSMsg>13900239223$break$13916809666$break$天之道损有余而补不足,是故虚胜实,不足胜有余$break$-YYFA'; len:=length(SendStr); GetMem(MSGData, len+sizeof(integer)+1); try MSGData.Strlength:=len; tmpPchar := pchar(SendStr); for i := 0 to len-1 do begin MSGData.Str := tmpPchar; end; MSGData.Str[len] := #0; memo1.lines.add(inttostr(len)); memo1.lines.add(inttostr(sizeof(integer)+len)); Messagebox(0,pchar(MSGData.Str),'',MB_OK); ClientSocket.Socket.Sendbuf(MSGData,sizeof(integer)+len); finally FreeMem(MSGData); end; end; 顺便问一下,ghb1974的代码不行吗?
V vigilsoft Unregistered / Unconfirmed GUEST, unregistred user! 2003-12-22 #24 修改一下 PMSGData=^TMSGData TMSGData=Record Strlength:integer; Strointer; end;
K kiths Unregistered / Unconfirmed GUEST, unregistred user! 2003-12-22 #25 那发送呢?长度怎么定?用什么函数发?楼上的兄弟有试过吗?
W weiwei81123 Unregistered / Unconfirmed GUEST, unregistred user! 2003-12-22 #26 sorry,i missed a '^': ClientSocket.Socket.Sendbuf(MSGData^,sizeof(integer)+len);