我想用spcomm控件写一个接收函数,不知道怎么写,我得要求是用shortstring类型或者pchar类型  有一本书上写的是string类型的。我不知道改下面我写出代码,请大家帮我改正
procedure ReadData;
var
  buffer:Pointer;
  BufferLength:Word;
begin
  SetLength(Receive,BufferLength);
  Move(Buffer^,pchar(Receive)^,BufferLength);
end;
其中receive为string类型,我改为shortstring时就出错了

解决方案 »

  1.   

    我想用spcomm控件写一个接收函数,不知道怎么写,我得要求是用shortstring类型或者pchar类型  有一本书上写的是string类型的。我不知道改下面我写出代码,请大家帮我改正
    procedure ReadData;
    var
      buffer:Pointer;
      BufferLength:Word;
    begin
      SetLength(Receive,BufferLength);
      Move(Buffer^,pchar(Receive)^,BufferLength);
    end;
    其中receive为string类型,我改为shortstring时就出错了
      

  2.   

    可能是你的bufferLength大于shortString的长度了