//大侠们好,再look 一 look ,解释一下
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, StdCtrls, Comobj, ActiveX;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TmR = record
v: integer;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function threadfunc(P: Pointer): LongInt;
stdcall;
begin
Tmr(P).v := 10;
//mr.v := 10;
这一句和上面的那一句有什么区别?
//CoInitialize(nil);
//CoUnInitialize;
Result := 0;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
id: Cardinal;
thrd: THandle;
mr : TmR;
begin
mr.v := 1;
thrd := CreateThread(nil, 0, @threadfunc, Pointer(mr), 0, id);
waitforsingleobject(thrd, INFINITE);
Caption := format('%d', [mr.v]);
end;
end.