⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scanportthreadunit.~pas

📁 DELPHI 下远程控制源码
💻 ~PAS
字号:
unit ScanPortThreadUnit;

interface

uses
  Classes, IdTCPClient,SysUtils,ComCtrls,IdWinsock, IdSocks;

type
  ScanPortThread = class(TThread)
  private
    { Private declarations }
  protected     
    SaveTL:TListView;
    ScanTheIP  :String;
    ScanThePort:integer;
    MyTcpClient:TIdTcpClient;
    TheScktInfo:TSocksInfo;       
    Procedure SaveIP;     
    procedure Execute; override;
  public
    Constructor Create(TheIP:String;ThePort:integer;TheTL:TListView);
    Destructor Destroy;override;
  end;

implementation
uses ScanIPUnit;
Constructor ScanPortThread.Create(TheIP:String;ThePort:integer;TheTL:TListView);
begin
  inherited Create(True);
  self.FreeOnTerminate:=True;
  ScanTheIP:=TheIP;
  ScanThePort :=ThePort;
  SaveTL:=TheTL;
  MyTcpClient:=TIdTcpClient.Create(nil);
  TheScktInfo:=TSocksInfo.Create;
    
  LetPingSingle.Enter;
    SdPingCount:=SdPingCount+1;
  LetPingSingle.Leave;

  self.Suspended:=False;
end;  

procedure ScanPortThread.Execute;
begin
  TheScktInfo.Authentication:=saNoAuthentication;
  TheScktInfo.Version:=svNoSocks;
  TheScktInfo.Port:=0;
  MyTcpClient.SocksInfo:=TheScktInfo;  
  MyTcpClient.UseNagle:=True;
  MyTcpClient.Host:=ScanTheIP;
  MyTcpClient.Port:=ScanThePort;
  try
   MyTcpClient.Connect;
  except
  end;
  if MyTcpClient.Connected then
  begin
     Synchronize(SaveIP);
     MyTcpClient.Disconnect;     
  end;
  Self.Terminate;
end;
Procedure ScanPortThread.SaveIP;
var
  TheListItem:TListItem;
begin
 try
  TheListItem:=SaveTL.Items.Add;
  TheListItem.ImageIndex:=0;
  TheListItem.Caption:=ScanTheIP;
  TheLIstItem.SubItems.Add('0');
  TheLIstItem.SubItems.Add('0');
  TheLIstItem.SubItems.Add('0');
  TheLIstItem.SubItems.Add('0');
  TheLIstItem.SubItems.Add(IntToStr(ScanThePort));
 except
 end;                                   
end;
Destructor ScanPortThread.Destroy;
begin 
  MyTcpClient.Free;
  TheScktInfo.Free;  
  LetPingSingle.Enter;
    SdPingCount:=SdPingCount-1;
  LetPingSingle.Leave;
  inherited Destroy;  
end;

end.
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -