MSComm串口控件在Delphi中的0字符接收例程详解

在Delphi中使用串口控件MSComm接收0字符时,可以使用以下例程:

procedure TForm1.MSComm1RxChar(Sender: TObject); 
begin 
if MSComm1.InBufferCount > 0 then 
begin 
  if MSComm1.Input = #0 then 
    // 处理0字符 
end; 
end; 

在这个例程中:

  • TForm1.MSComm1RxChar是MSComm控件接收字符时触发的方法。
  • MSComm1.InBufferCount属性表示接收缓冲区中的字符数。
  • MSComm1.Input属性返回接收到的字符。
  • 如果MSComm1.Input等于0,表示接收到了0字符。
doc 文件大小:50.5KB