中国开发网: 论坛: 程序员情感CBD: 贴子 278337
HGRhgr
InPutCount>0表示幵始返回,返回完该值重置位为0,还不能判断吗?我以前是这样做的,不知是否适合你
var
LastInputCount: integer=0;
procedure TForm1.ComPortRxChar(Sender: TObject; Count: Integer);
var
Str: String;
begin
repeat
LastInputCount := ComPort.InputCount;
Sleep(10); //等待时间,可设置。
until LastInputCount = ComPort.InputCount; //前后二交比较,看有无增加

LastInputCount := 0;

ComPort.ReadStr(Str, ComPort.InputCount);
Memo.Lines.Add(Str);

end;

还有一种办法是用一个时钟事件,不停的扫描.

PS:有什么好办法,希望到时告诉我一下.

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录