1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
Procedure TThread1.UpdateBar;
begin
MainForm.bar.Position := MainForm.Bar.Position + 1;
end;
Procedure TThread1.UpdateList;
begin
MainForm.Portlist.Items.Add.Caption := ListPorts1[j];
MainForm.Portlist.Items.Item[MainForm.Portlist.Items.Count - 1].SubItems.Add(ListOpen1[j]);
MainForm.Portlist.ItemIndex := MainForm.Portlist.Items.Count - 1;
end;
procedure TThread1.Execute;
var
i,k : integer;
begin
FreeOnTerminate := False;
Priority := tpNormal;
ListPorts1 := TStringList.Create;
ListOpen1 := TStringList.create;
ListPorts1.Clear;
ListOpen1.Clear;
If Ports1 <=0 then Begin Finished1 := true; Exit; End;
Finished1 := false;
For i:= PDebut to PDebut+Ports1 do
begin
listPorts1.add(IntToStr(i));
If not Scanning then break;
Try
Synchronize(Thread1,UpdateBar);
MainForm.TCP1.Port := i;
MainForm.TCP1.Connect(100);
listOpen1.Add('Ouvert');
Except
listOpen1.Add('Fermé');
end;
// MainForm.TCP1.disconnect
end;
Finished1 := true;
If Scanning then
begin
For k := 0 to ListPorts1.Count-1 do
begin
j := k;
Synchronize(Thread1,UpdateList);
end;
end;
ListPorts1.Free;
ListOpen1.Free;
end; |
Partager