绝
绝对新手
Unregistered / Unconfirmed
GUEST, unregistred user!
我是新手 看不太明白 请大虾帮忙逐句注释下用途 感激不尽
procedure TForm1.OnCaseSvrData(ISender: TudpCtl; IData: Pointer; ISize:
Cardinal; IFromIP: string; IPort: integer);
var
Lp, LTep: PChar;
begin
with ISender do begin
case PInteger(IData)^ of //
1: begin
LTep := IData;
Edit2.Text := IntToStr(ISize);
Lp := GetMemory(ISize);
inc(LTep, Sizeof(rhead));
CopyMemory(Lp, LTep, ISize);
Memo2.Text := StrPas(Lp);
FreeMemory(Lp);
end;
end; // case
end; // with
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Lhead: Rhead;
LP: PChar;
begin
Lhead.Id := 1;
Lmem.Position := 0;
Lmem.WriteBuffer(lHead, Sizeof(Lhead));
LP := GetMemory(Memo1.GetTextLen + 1);
Lmem.SetSize(Memo1.GetTextLen + 1);
Memo1.GetTextBuf(LP, Memo1.GetTextLen + 1);
Lmem.WriteBuffer(lp^, Memo1.GetTextLen + 1);
FreeMemory(LP);
ClientUdpCtl.RemoteHost := Edit2.Text;
ClientUdpCtl.PeerSize := StrToInt(Edit5.Text);
ClientUdpCtl.ReSendTime := StrToInt(Edit3.Text);
ClientUdpCtl.FreeWindowsCount := StrToInt(Edit4.Text);
ClientUdpCtl.SleepTime := StrToInt(Edit6.Text);
ClientUdpCtl.SafeSendBuff(Lmem.Memory^, Lmem.Size);
Edit1.Text := IntToStr(Lmem.Size);
end;
procedure TForm1.OnCaseSvrData(ISender: TudpCtl; IData: Pointer; ISize:
Cardinal; IFromIP: string; IPort: integer);
var
Lp, LTep: PChar;
begin
with ISender do begin
case PInteger(IData)^ of //
1: begin
LTep := IData;
Edit2.Text := IntToStr(ISize);
Lp := GetMemory(ISize);
inc(LTep, Sizeof(rhead));
CopyMemory(Lp, LTep, ISize);
Memo2.Text := StrPas(Lp);
FreeMemory(Lp);
end;
end; // case
end; // with
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Lhead: Rhead;
LP: PChar;
begin
Lhead.Id := 1;
Lmem.Position := 0;
Lmem.WriteBuffer(lHead, Sizeof(Lhead));
LP := GetMemory(Memo1.GetTextLen + 1);
Lmem.SetSize(Memo1.GetTextLen + 1);
Memo1.GetTextBuf(LP, Memo1.GetTextLen + 1);
Lmem.WriteBuffer(lp^, Memo1.GetTextLen + 1);
FreeMemory(LP);
ClientUdpCtl.RemoteHost := Edit2.Text;
ClientUdpCtl.PeerSize := StrToInt(Edit5.Text);
ClientUdpCtl.ReSendTime := StrToInt(Edit3.Text);
ClientUdpCtl.FreeWindowsCount := StrToInt(Edit4.Text);
ClientUdpCtl.SleepTime := StrToInt(Edit6.Text);
ClientUdpCtl.SafeSendBuff(Lmem.Memory^, Lmem.Size);
Edit1.Text := IntToStr(Lmem.Size);
end;