鱼C论坛

 找回密码
 立即注册

鱼C扫描器

已有 632 次阅读2015-1-12 23:29 |个人分类:delphi学习

源代码

unit Unit1;


interface


uses

  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,

  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Imaging.jpeg, Vcl.ExtCtrls,

  Vcl.StdCtrls, Vcl.ComCtrls, System.Win.ScktComp;


type

  TForm1 = class(TForm)

    Image1: TImage;

    Label1: TLabel;

    Edit1: TEdit;

    Label2: TLabel;

    Edit2: TEdit;

    Label3: TLabel;

    Edit3: TEdit;

    Label4: TLabel;

    Edit4: TEdit;

    Panel1: TPanel;

    Panel2: TPanel;

    Panel3: TPanel;

    Label5: TLabel;

    Label6: TLabel;

    ProgressBar1: TProgressBar;

    Timer1: TTimer;

    ClientSocket1: TClientSocket;

    ListBox1: TListBox;

    procedure FormCreate(Sender: TObject);

    procedure Panel1Click(Sender: TObject);

    procedure Timer1Timer(Sender: TObject);

    procedure Panel3Click(Sender: TObject);

    procedure Panel2Click(Sender: TObject);

    procedure Edit3Change(Sender: TObject);

    procedure Edit2Change(Sender: TObject);

    procedure Edit1Change(Sender: TObject);

    procedure ClientSocket1Connect(Sender: TObject; Socket: TCustomWinSocket);

    procedure ClientSocket1Error(Sender: TObject; Socket: TCustomWinSocket;

      ErrorEvent: TErrorEvent; var ErrorCode: Integer);

    procedure ClientSocket1Disconnect(Sender: TObject;

      Socket: TCustomWinSocket);

  private

    { Private declarations }

  public

    { Public declarations }

  end;


var

  Form1: TForm1;


implementation


{$R *.dfm}


procedure TForm1.ClientSocket1Connect(Sender: TObject;

  Socket: TCustomWinSocket);

begin

  ListBox1.Items.Add('端口: ' + inttostr(clientsocket1.port));

  ClientSocket1.Close;

  if Edit3.Text = IntToStr(ProgressBar1.position) then

  begin


    Timer1.Enabled := False;

    //ClientSocket1.Close;

  end;

end;


procedure TForm1.ClientSocket1Disconnect(Sender: TObject;

  Socket: TCustomWinSocket);

begin

  Timer1.Enabled := True;

end;


procedure TForm1.ClientSocket1Error(Sender: TObject; Socket: TCustomWinSocket;

  ErrorEvent: TErrorEvent; var ErrorCode: Integer);

begin

  ErrorCode:= 0;

end;


procedure TForm1.Edit1Change(Sender: TObject);

begin

  ClientSocket1.Address := Edit1.Text;

end;


procedure TForm1.Edit2Change(Sender: TObject);

begin

  ProgressBar1.Min := StrToInt(Edit2.Text);

  ProgressBar1.Position:= ProgressBar1.Min;

end;


procedure TForm1.Edit3Change(Sender: TObject);

begin

  ProgressBar1.Max := StrToInt(edit3.Text);

end;


procedure TForm1.FormCreate(Sender: TObject);

begin

  Form1.Height:= 480;

  Form1.Width:= 640;

  Form1.AutoSize:= true;

  Form1.BorderStyle:= bsDialog;

  Panel3.Left:= 519;

  Panel3.Top := 353;

  ProgressBar1.Max:= StrToInt(Edit3.Text);

  Timer1.Interval := StrToInt(Edit4.Text);

end;


procedure TForm1.Panel1Click(Sender: TObject);

begin

  if (panel1.Caption = '扫描') then

    begin

      Panel3.Visible := True;

      Panel1.Caption := '停止扫描';

      Timer1.Interval := StrToInt(Edit4.Text);

      Timer1.Enabled := True;

      ListBox1.Clear;

      ProgressBar1.Position := StrToInt(Edit2.Text);

      Label5.Caption := '端口:' + ' ' + IntToStr(progressbar1.Position);

    end

  else

    begin

      Panel1.Caption := '扫描';

      Panel3.Visible := False;

      Timer1.Enabled := False;

      ProgressBar1.Position:= 0;

      Label5.Caption := '端口:' + ' ' + IntToStr(progressbar1.Position);


    end;


end;


procedure TForm1.Panel2Click(Sender: TObject);

begin

  Form1.close;

end;


procedure TForm1.Panel3Click(Sender: TObject);

begin

  if Panel3.Caption = '暂停扫描' then

    begin

      Timer1.Enabled := False;

      Panel3.Caption := '继续扫描';

    end

  else

    begin

      Timer1.Enabled := True;

      Panel3.Caption := '暂停扫描';

    end;


end;


procedure TForm1.Timer1Timer(Sender: TObject);

begin

  if ProgressBar1.Position = StrToInt(Edit3.Text) then

    begin

      Timer1.Enabled:= False;

      ClientSocket1.Port:= ProgressBar1.Position;

      Panel3.Visible:= False;

      Panel1.Caption := '扫描';

      Label5.Caption := '端口:' + ' ' + IntToStr(progressbar1.Position);

      //ProgressBar1.Position:= 0;

      //Label5.Caption := '端口:' +  ' ' + IntToStr(progressbar1.Position);


    end

  else

    begin

      Label5.Caption := '端口:' +  ' ' + IntToStr(progressbar1.Position);

      ClientSocket1.Port:= ProgressBar1.Position;

      ClientSocket1.Address := Edit1.Text;

      ClientSocket1.Open;

      ProgressBar1.StepIt;


    end;

end;


end.


路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-2 21:12

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

返回顶部