代码应该没问题, 只是用在不同的目标上效果不一样, 我想知道cisco路由器和电信的se800这两个设备在用这个控件上要注意什么区别吗?这是代码: procedure TfrmTelnetDemo.IdTelnetDemoDataAvailable(Buffer: string); {This routine comes directly from the ICS TNDEMO code. Thanks to Francois Piette It updates the memo control when we get data} const CR = #13; LF = #10; var Start, Stop: Integer; begin memo1.Lines.Add(buffer); if Memo1.Lines.Count = 0 then Memo1.Lines.Add(''); Start := 1; Stop := Pos(CR, Buffer); if Stop = 0 then Stop := Length(Buffer) + 1; while Start <= Length(Buffer) do begin Memo1.Lines.Strings[Memo1.Lines.Count - 1] := Memo1.Lines.Strings[Memo1.Lines.Count - 1] + Copy(Buffer, Start, Stop - Start); if Buffer[Stop] = CR then begin Memo1.Lines.Add(''); SendMessage(Memo1.Handle, WM_KEYDOWN, VK_UP, 1); end; Start := Stop + 1; if Start > Length(Buffer) then Break; if Buffer[Start] = LF then Start := Start + 1; Stop := Start; while (Buffer[Stop] <> CR) and (Stop <= Length(Buffer)) do Stop := Stop + 1; end; end;
procedure TfrmTelnetDemo.IdTelnetDemoDataAvailable(Buffer: string);
{This routine comes directly from the ICS TNDEMO code. Thanks to Francois Piette
It updates the memo control when we get data}
const
CR = #13;
LF = #10;
var
Start, Stop: Integer;
begin
memo1.Lines.Add(buffer);
if Memo1.Lines.Count = 0 then
Memo1.Lines.Add(''); Start := 1;
Stop := Pos(CR, Buffer);
if Stop = 0 then
Stop := Length(Buffer) + 1;
while Start <= Length(Buffer) do
begin
Memo1.Lines.Strings[Memo1.Lines.Count - 1] :=
Memo1.Lines.Strings[Memo1.Lines.Count - 1] +
Copy(Buffer, Start, Stop - Start);
if Buffer[Stop] = CR then
begin
Memo1.Lines.Add(''); SendMessage(Memo1.Handle, WM_KEYDOWN, VK_UP, 1); end;
Start := Stop + 1;
if Start > Length(Buffer) then
Break;
if Buffer[Start] = LF then
Start := Start + 1;
Stop := Start;
while (Buffer[Stop] <> CR) and (Stop <= Length(Buffer)) do
Stop := Stop + 1;
end;
end;