创建线程的老问题(50分)

  • 主题发起人 迷惘的人
  • 开始时间

迷惘的人

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
procedure show;
begin
form1.Label1.Caption:=inttostr(strtoint(form1.Label1.Caption)*2);
form1.Label2.Caption:=inttostr(strtoint(form1.Label1.Caption)*2);
end;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var hhandle:THandle;
ThreadID:DWord;
begin
hhandle:=CreateThread(nil,0,@show,nil,0,ThreadID);
if ThreadID=0 then
messagebox(handle,'线程建立失败',nil,MB_ok);
end;

end.
创建线程时,系统老是报错:
[Error] Unit1.pas(37): Variable required
希望各位大虾指点迷津!
 
难道大家都束手无策?
 
把show改成别的,它以为你在调用Form1.Show。线程函数要有一个指针类型
的参数,调用方式stdcall.
procedure show1(Data: pointer);
stdcall;
 
接受答案了.
 
顶部