Просмотр кода
Идентификатор: d11fe7bb Описание: Код загружен: 13 июля 2011, 19:04 (Моисеев Евгений Леонидович)
unit Unit8; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Sockets, StdCtrls; type TForm8 = class(TForm) Label1: TLabel; Edit1: TEdit; Label2: TLabel; Edit2: TEdit; memo1: TMemo; Button1: TButton; TcpClient1: TTcpClient; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form8: TForm8; implementation {$R *.dfm} procedure TForm8.Button1Click(Sender: TObject); var i:Integer; ip:String; begin ip:='127.0.0.1'; //По умолчанию сканируем себя if not InputQuery('Attention','Enter IP-address',ip) then exit; //Запрашиваем адрес компа. for i:=StrToInt(Edit1.Text) to StrToInt(Edit2.Text) do //Запускаем цикл begin TcpClient1.RemotePort:=IntToStr(i); //Устанавливаем порт TcpClient1.Open; //Пытаемся его открыть if TcpClient1.Connected then Memo1.Lines.Add(IntToStr(i)+' open'); //Если удалось, то сообщаем об этом TcpClient1.Close; //Закрываем порт. end; end; end.