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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
ListBox1: TListBox;
BitBtn2: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
Unit2;
Type
PTestThread = ^TTestThread;
Var
IpToTest : TStringList;
ThreadList : TList;
TestThread : PTestThread;
MaxThreads : Integer;
i : Integer;
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
i := 0;
while i < IpToTest.count do
begin
if ThreadList.count <= MaxThreads then
begin
new(TestThread);
TestThread^.create(true);
TestThread^.FreeOnTerminate := true;
TestThread^.resume;
ThreadList.add(TestThread);
inc(i);
end;
end;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var
openDialog : TOpenDialog;
begin
openDialog := TOpenDialog.Create(self);
try
openDialog.InitialDir := GetCurrentDir;
openDialog.Options := [ofFileMustExist];
openDialog.Filter := 'Tous les fichiers|*.*';
openDialog.FilterIndex := 2;
if openDialog.Execute then begin
IpToTest.LoadFromFile(openDialog.FileName);
ListBox1.Items.LoadFromFile(openDialog.FileName);
end;
finally
openDialog.Free;
end;
end;
Initialization
IpToTest := TStringList.Create;
ThreadList := TList.Create;
Finalization
IpToTest.Free;
ThreadList.Free;
end. |
Partager