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
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdAntiFreezeBase, IdAntiFreeze, IdBaseComponent,
IdComponent, IdTCPConnection, IdTCPClient;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Button2: TButton;
Edit2: TEdit;
Memo1: TMemo;
IdTCPClient1: TIdTCPClient;
IdAntiFreeze1: TIdAntiFreeze;
procedure Button1Click(Sender: TObject);
procedure IdTCPClient1Connected(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
P : Integer;
po : string ;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
P:= 1; // Port min
repeat
with IdTCPClient1 do
begin
Host := edit1.Text; // L'IP biensur
Port := P;
Str(P, po);
P := P + 1; // Incrementation des ports
Edit2.Text := po; // Affiche les ports en cours de scan
try
Connect(500);
except
on E : Exception do // Pour les Ports non-ouverts.
begin
po := ''; // Permet d'afficher dans memo1 que les ports ouverts
end;
end;
Memo1.Text := Memo1.Text + po;
end;
until P = 65500 // Port max
end;
procedure TForm1.IdTCPClient1Connected(Sender: TObject);
begin
IdTCPClient1.Disconnect; // Deconnecter si port ouvert
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
Memo1.clear;
end;
end. |
Partager