小例子参考下
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
aArray: array of integer;
type
info= array of integer;
pinfo= ^info;
procedure TForm1.Button1Click(Sender: TObject);
procedure myThread1(ainfo: pinfo);stdcall;
begin
ainfo^[0]:= 3;
end;
var
th1: Cardinal;
begin
setlength(aArray,5);
aArray[0]:= 1;
aArray[1]:= 2;
aArray[2]:= 3;
aArray[3]:= 4;
aArray[4]:= 5;
CreateThread(nil,0,@myThread1,@aArray,0,th1);
sleep(100);
showmessage(IntToStr(aArray[0]));
end;
end.