//复合语句你怎么不加begin..endprocedure TForm1.Button1Click(Sender: TObject); var I: Integer; begin {停止扫描端口} if Button1.Caption = '开始扫描(&C)' then begin Button1.Caption := '停止(&S)'; Animate1.Active := False; for I := 1 to 65535 do {遍历所有端口号} begin ClientSocket1.Port := I; ClientSocket1.Active := False; end end else begin {开始扫描端口} Button1.Caption := '开始扫描(&C)'; Animate1.Active := True; ClientSocket1.Address := Edit1.Text;{设置被扫描主机IP地址} for I := 1 to 65535 do {遍历所有端口号} begin ClientSocket1.Active := False; ClientSocket1.Port := I; ClientSocket1.Socket.Data := Pointer(I);//待会根据这个判断哪个端口连上了 ClientSocket1.Active := True; end; end; end;
我是新手,多谢 zswang(伴水)(* pascal→c *) !!
If Button1.Caption='开始扫描(&C)' THen begin<----------------------------- Button1.Caption:= '停止(&S)'; Animate1.Active:=False; for i:=1 to 65535 do {遍历所有端口号} begin ClientSocket1.Port:=i; ClientSocket1.Active:=False; end; end<--------------------------------- 这样就可以了,ok?
var
I: Integer;
begin
{停止扫描端口}
if Button1.Caption = '开始扫描(&C)' then
begin
Button1.Caption := '停止(&S)';
Animate1.Active := False;
for I := 1 to 65535 do {遍历所有端口号}
begin
ClientSocket1.Port := I;
ClientSocket1.Active := False;
end
end
else
begin
{开始扫描端口}
Button1.Caption := '开始扫描(&C)';
Animate1.Active := True;
ClientSocket1.Address := Edit1.Text;{设置被扫描主机IP地址}
for I := 1 to 65535 do {遍历所有端口号}
begin
ClientSocket1.Active := False;
ClientSocket1.Port := I;
ClientSocket1.Socket.Data := Pointer(I);//待会根据这个判断哪个端口连上了
ClientSocket1.Active := True;
end;
end;
end;
begin<-----------------------------
Button1.Caption:= '停止(&S)';
Animate1.Active:=False;
for i:=1 to 65535 do {遍历所有端口号}
begin
ClientSocket1.Port:=i;
ClientSocket1.Active:=False;
end;
end<---------------------------------
这样就可以了,ok?