C
Cody.w
Unregistered / Unconfirmed
GUEST, unregistred user!
原代码是这样的:procedure TForm1.Button1Click(Sender: TObject);var Buf:array of byte; tempstr:string; contrallen:integer; mStream:TMemoryStream;begin //发送 tempstr:=RxRichEdit1.Text; contrallen:=16; setlength(Buf,contrallen+sizeof(integer)+length(tempstr)+1); for i:=0 to contrallen-1 do if ((i mod 2)=0 ) then buf:=$F else buf:=$A; Pinteger(@Buf[contrallen])^:=11; copymemory(@Buf[contrallen+sizeof(integer)],@tempstr[1],length(tempstr)); Buf[length(buf)-1]:=0; ClientS.Socket.SendBuf(buf[0],length(buf));end;这样可以正常发送;现在遇到个问题是,RxRichEdit里插入了图像,如果我想图像文字混合着发送的话,直接用RxRichEdit.text发送出去是不行的,我想到的是RxRichEdit.Lines.SaveToStream,然后再由得到的流转为buff发送,比如: mStream:=TMemoryStream.Create; mStream.Position:=0; RxRichEdit1.Lines.SaveToStream(mStream); mStream.Position:=0;到这里我就不知道该怎么做了,期盼厉害的大大帮忙想想TMemoryStream有个WriteBuff()我想mStream.WriteBuff(buf,count{这个不知道怎么获取})然后再用Socket.SendBuf(buf.......)