下面是接受程序:
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
  BufferLength: Word);
begin
  SetLength(strInput, BufferLength);
  Move(Buffer^, PChar(StrInput)^, BufferLength);
  memo1.lines.add(StrInput);
  memo1.lines.add('');
end;谢谢各位大虾

解决方案 »

  1.   

    Move(Buffer^, PChar(StrInput)^, BufferLength);
    改成:
    var
    StrInput : array[0..100] of byte;Move(Buffer^, StrInput, BufferLength);
    这样对(StrInput[i],2)操作。
    你试试看,行不行!?
      

  2.   

    可是StrInput已经在前面声明类型了,我怎样在二者不矛盾冲突的情况下进行定义呢
    var
      Form1: TForm1;
      viewstring:string;
      i:integer;
      strInput: string;implementation{$R *.dfm}procedure TForm1.FormShow(Sender: TObject);
    begin
      comm1.StartComm;
    end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      comm1.StopComm;
    end;procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
      BufferLength: Word);
    begin
      SetLength(strInput, BufferLength);
      Move(Buffer^, PChar(StrInput)^, BufferLength);
      memo1.lines.add(StrInput);
      memo1.lines.add('');
    end;
      

  3.   

    procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
      BufferLength: Word);
    var str:Array[0..2047] of byte;
        i:integer;
    begin
      Move(Buffer^, str, BufferLength);
      for i:=0 to length(str) do
      begin
        memo1.lines.add(str[i]); 
        memo1.lines.add('');
      end;
    end;