PortScan.pas
上传用户:hbtcygglw
上传日期:2007-01-07
资源大小:281k
文件大小:1k
源码类别:

其他

开发平台:

Delphi

  1. unit PortScan;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   ExtCtrls, StdCtrls, Buttons, NMUDP, Spin;
  6. type
  7.   TScannerDlg = class(TForm)
  8.     SendList: TListBox;
  9.     Splitter1: TSplitter;
  10.     RecvList: TListBox;
  11.     btnScan: TBitBtn;
  12.     BitBtn2: TBitBtn;
  13.     edStartAddr: TEdit;
  14.     Label1: TLabel;
  15.     Label2: TLabel;
  16.     ScanUdp: TNMUDP;
  17.     edAddrNum: TSpinEdit;
  18.     procedure btnScanClick(Sender: TObject);
  19.   private
  20.     { Private declarations }
  21.     procedure PingAddr(addr:string);
  22.   public
  23.     { Public declarations }
  24.     class procedure Execute;
  25.   end;
  26. implementation
  27. uses main;
  28. {$R *.DFM}
  29. procedure TScannerDlg.btnScanClick(Sender: TObject);
  30. var
  31. i:Integer;
  32. addr:string;
  33. begin
  34. for i:=1 to edAddrNum.Value do
  35.     begin
  36.     addr:=edStartAddr.Text+'.'+IntToStr(i);
  37.     PingAddr(addr);
  38.     PingAddr(addr);
  39.     PingAddr(addr);
  40.     end;
  41. end;
  42. class procedure TScannerDlg.Execute;
  43. begin
  44. with TScannerDlg.Create(Application) do
  45.     begin
  46.     ShowModal;
  47.     Free;
  48.     end;
  49. end;
  50. procedure TScannerDlg.PingAddr(addr: string);
  51. {var
  52. buf:array [0..2048] of char;
  53. i:Integer;}
  54. begin
  55. SendList.Items.Add('Scanning address:'+addr);
  56. end;
  57. end.