关于CreateThread()中的参数lpParameter如何使用?lpParameter是指线程的执行函数的参数地址,那我在执行函数中如何得到这个参数!最好有个简单例子!谢谢!
解决方案 »
- TFilterPredicate返回值问题
- 数据库连接问题
- 如何在DBGRID的各单元格,当数值发生变化时,执行一段代码呢,,不想在DataSet处理!
- 求一SQL语句
- 高手进来说说怎么公用的变量和自定义函数放在程序中什么位置比较好!?如果用一个单独的文件呢又存行不行?程序中的其它模块怎样调用他们
- listview
- 散分,求一串口问题
- 一触发器的问题,详情请进!
- 谁有Windows2000下的softice ?
- SQL2000的问题,在连接过程中出现SQLconnection property required for this operation
- 如何去掉TImage里边的图片
- 请问我是DEPHI 6 + window 2000 + sql server , 在这样的环境下,我还需要安装ADO补丁吗
TPingIPThread = class(TThread)
private
{ Private declarations }
FchannelStr:string;
FcolInt:integer;
protected
procedure Execute; override;
public
constructor Create(par_channelStr:string;Par_colInt:integer);
end;
implementation
uses poskjg;{ TPingIPThread }procedure TPingIPThread.Execute;
begin
poskjgfrm.wangluozhuangtai(FchannelStr,FcolInt);
end;constructor TPingIPThread.Create(par_channelStr:string;Par_colInt:integer);
begin
FchannelStr:=par_channelStr;
FcolInt:=Par_colInt;
FreeOnTerminate:=true;
inherited Create(True);
end;
var
Form1: TForm1;
ThreadHandle: THandle;implementation{$R *.DFM}function ThreadFunc(Info: Pointer): Integer; stdcall;
begin
Form1.Edit1.Text := 'Hello from the thread!';
Sleep(1000);
ExitThread(4);
end;procedure TForm1.Button1Click(Sender: TObject);
var
ThreadId1: DWORD;
begin
ThreadHandle := CreateThread(nil, 0, @ThreadFunc, nil, 0, ThreadId1);
end;
lpThreadAttributes: Pointer; {a pointer to a TSecurityAttributes structure}
dwStackSize: DWORD; {initial stack size of the thread in bytes}
lpStartAddress: TFNThreadStartRoutine; {address of the thread routine}
lpParameter: Pointer; {argument of the new thread}
dwCreationFlags: DWORD; {creation flags}
var lpThreadId: DWORD {address of the thread id}): THandle; {returns the handle of the new thread}具体祥见MSDN
能否举个简单例子吗?谢谢
Form1: TForm1;
ThreadHandle: THandle;implementation{$R *.DFM}function ThreadFunc(Info: Pointer): Integer; stdcall;
begin
Form1.Edit1.Text := 'Hello from the thread!';
Sleep(1000);
ExitThread(4);
end;procedure TForm1.Button1Click(Sender: TObject);
var
ThreadId1: DWORD;
begin
ThreadHandle := CreateThread(nil, 0, @ThreadFunc, nil, 0, ThreadId1);
end;