首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

spcomm发送和接受的代码 !

2012-02-22 
spcomm发送和接受的代码高手指点!!!!procedure TForm1.Button1Click(Sender: TObject)beginsenddata(edit

spcomm发送和接受的代码 高手指点!!!!
procedure TForm1.Button1Click(Sender: TObject);
begin
 senddata(edit1.text); 发送edit1中的字符串
 edit2.Text :=recdata; 接受到的字符串显示在edit2中



procedure senddata(s:string); 发送函数没有问题
var comandstr:string;
begin
  comandstr:=s+char(13);
  form1.comm1.writecommdata(pchar(ComandStr),length(ComandStr));
end;

procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;接受函数 edit2不能显示收到的字符串 BufferLength: Word);
begin
  move(Buffer^, PChar(@RecData[1])^, BufferLength);
end;


[解决办法]

Delphi(Pascal) code
SetLength(RecData,BufferLength);move(Buffer^, PChar(@RecData[1])^, BufferLength);edit2.text:=RecData 

热点排行