Delphi高手过来帮帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/01 10:16:36
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
ListBox1: TListBox;
BtnPing: TButton;
BtnClearText: TButton;
BtnUseThread: TBitBtn;
ICMP: TIdIcmpClient;
SpinEdit1: TSpinEdit;
procedure BtnUsedThreadClick(Sender: TObject);
procedure ICMPReply(ASender:TComponent;const AReplyStatus:TReplyStatus);
procedure BtnpingClick(Sender: TObject);
procedure BtnClearTextClick(Sender: TObject);

function MyThreadFunc(P:pointer ):Longint;
var icmp: TIdIcmpClient;
begin
ICMP := TIdIcmpClient.Create(nil);
ICMP.Host := form1.Edit1.Text ;
ICMP.ReceiveTimeout := 500;
ICMP.OnReply := Form1.ICMPReply;
ICMP.Ping;
end;

procedure TForm1.BtnUsedThreadClick(Sender: TObject);
var
hThread:Thandle;
ThreadID:DWord;
i:integer ;
begin //创建线程,同时线程函数被调用

[Warning] Unit1.pas(47): Return value of function 'MyThreadFunc' might be undefined
函数 MyThreadFunc 未声明

function MyThreadFunc(P:pointer ):Longint;
作为一个函数 你的result是什么?
我觉的你这部分写成过程就可以了,你只是实例化了一个TIdIcmpClient
hThread没有初始化,但是单独测试了下BtnUsedThreadClick这部分,似乎也能编译通过