谁用过spcomm控件,给我一点意见

我想用spcomm控件写一个接收函数,不知道怎么写,我得要求是用shortstring类型或者pchar类型 有一本书上写的是string类型的。我不知道改。。。下面我写出代码,请大家帮我改正
procedure ReadData;
var
buffer:Pointer;
BufferLength:Word;
begin
SetLength(Receive,BufferLength);
Move(Buffer^,pchar(Receive)^,BufferLength);
end;
其中receive为string类型,我改为shortstring时就出错了
☆★○●◎◇◆□■△▲※
我菜
不全是我的错
因为
我认识了你们
~~~~~~~~~~~~~~~~~~~~~~~~
[436 byte] By [jyinhan-风零落] at [2008-2-13]
# 1
shortstring长度最大256,不太合适吧?
那就用pchar吧!
var
receive : Pchar;
begin
GetMem(receive,Bufferlength +1);
Move(buffer^, receive^,BufferLength);

...
FreeMem(receive);
end;
最后,使用pchar不是太好,如果接收的字符中间有0就出问题了,建议你最好用string
shaver at 2007-10-22 > top of Msdn China Tech,Delphi,VCL组件开发及应用...