例:000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0000=40.0
object Comm1: TComm
CommName = 'COM1'
BaudRate = 1200
ParityCheck = False
Outx_CtsFlow = False
Outx_DsrFlow = False
DtrControl = DtrEnable
DsrSensitivity = False
TxContinueOnXoff = True
Outx_XonXoffFlow = False
Inx_XonXoffFlow = False
ReplaceWhenParityError = False
IgnoreNullChar = False
RtsControl = RtsEnable
XonLimit = 500
XoffLimit = 500
ByteSize = _8
Parity = None
StopBits = _1
XonChar = #17
XoffChar = #19
ReplacedChar = #0
ReadIntervalTimeout = 500
ReadTotalTimeoutMultiplier = 0
ReadTotalTimeoutConstant = 0
WriteTotalTimeoutMultiplier = 0
WriteTotalTimeoutConstant = 0
OnReceiveData = Comm1ReceiveData
Left = 144
Top = 65528
end
object Comm1: TComm
CommName = 'COM1'
BaudRate = 1200
ParityCheck = False
Outx_CtsFlow = False
Outx_DsrFlow = False
DtrControl = DtrEnable
DsrSensitivity = False
TxContinueOnXoff = True
Outx_XonXoffFlow = False
Inx_XonXoffFlow = False
ReplaceWhenParityError = False
IgnoreNullChar = False
RtsControl = RtsEnable
XonLimit = 500
XoffLimit = 500
ByteSize = _8
Parity = None
StopBits = _1
XonChar = #17
XoffChar = #19
ReplacedChar = #0
ReadIntervalTimeout = 500
ReadTotalTimeoutMultiplier = 0
ReadTotalTimeoutConstant = 0
WriteTotalTimeoutMultiplier = 0
WriteTotalTimeoutConstant = 0
OnReceiveData = Comm1ReceiveData
Left = 144
Top = 65528
end
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
tmpArray:array[0..4096] of Byte;
ArraySize,i: DWORD;
Count:DWORD;
tmpStr:string;
pStr:PChar;
begin
pStr:= Buffer;
memo2.Lines.Add(pStr);
end;
move(Buffer^,s1[1],BufferLength);
Memo1.Lines.Add(tmpStr);
BufferLength: Word);
事件的。应该说楼主的 写法也可以啊 但是如果每次接收的数据长度 不同的话 就有可能出现错误 所以还是楼上的 代码安全!
getit911(Windows转Linux中) ( ) 信誉:100 2006-06-19 16:37:00 得分: 0
setlength(tmpStr,BufferLength);
move(Buffer^,s1[1],BufferLength);
Memo1.Lines.Add(tmpStr);