Na formie1 - Memo1 (Kopiowane są do niej aktywne IP), Listbox1 (zawiera listę przygotowanych wcześniej numerów IP), Edit1 (zawiera numer portu), IdIcmpClient1, Button1 (Uaktywnia proces - wątek przeszukiwania).
Problem?
- Nie mogę uruchomić pętli w wątku - problem z uruchomieniem wątku. Poniższy kod nie kompiluje się, wywala błąd [Error] Unit1.pas(64): This form of method call only allowed for class methods.
- Aplikacja ping-uje jak widać. Jeżeli serwer odpowie określoną automatyczną wiadomością na ping - da radę to jakoś przechwycić? I czy da radę ping wysłać o określonej treści? I żeby nie trwało to całą wieczność...
Kod:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdRawBase, IdRawClient,
IdIcmpClient;
type
TForm1 = class(TForm)
IdIcmpClient1: TIdIcmpClient;
Button1: TButton;
Memo1: TMemo;
Label1: TLabel;
ListBox1: TListBox;
Edit1: TEdit;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TWatek = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
end;
var
Form1: TForm1;
implementation
procedure TWatek.Execute;
var
i:integer;
IPtxt:string;
begin
repeat
i:=form1.Listbox1.Items.Count;
IPtxt:=form1.listbox1.Items.Strings[i-1];
form1.IdICMPClient1.Host:=(IPtxt);
form1.IdICMPClient1.Port:=strtoint(form1.edit1.Text);
form1.IdICMPClient1.Ping;
If form1.IdICMPClient1.ReplyStatus.ReplyStatusType=rsEcho then form1.Memo1.Lines.Add(IPtxt);
if i>0 then
form1.Listbox1.Items.Delete(i-1);
until((i) = 1);
end;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
TWatek.resume;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
TWatek.Create(true);
end;
end.