Z
zjlcc
Unregistered / Unconfirmed
GUEST, unregistred user!
问题是:运行中途时不时的会出错!另外我只想用WINAPI解决,别跟我说用TThread
unit Unit1;
interface
uses
Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
function kk(Pointer):Longint;stdcall;
function kk1(Pointer):Longint;stdcall;
implementation
{$R *.DFM}
function kk(Pointer):Longint;stdcall;
var
a:integer;
begin
Form1.label1.caption:='0';
for a:=1 to 100000 do begin
form1.label1.caption:=inttostr(strtoint(form1.label1.caption)+1);
// Application.ProcessMessages;
end;
end;
function kk1(Pointer):Longint;stdcall;
var
a:integer;
begin
Form1.label2.caption:='0';
for a:=1 to 100000 do begin
form1.label2.caption:=inttostr(strtoint(form1.label2.caption)+1);
//Application.ProcessMessages;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
hthread,a:thandle;
threadID,bword;
s:string;
begin
// hthread:=createthread(nil,18129,@kk, nil,0,threadid);
// a :=createthread(nil,18129,@kk1,nil,0,b);
CloseHandle(createthread(nil,64000,@kk, nil,0,threadid));
CloseHandle(createthread(nil,64000,@kk1,nil,0,b));
end;
end.
unit Unit1;
interface
uses
Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
function kk(Pointer):Longint;stdcall;
function kk1(Pointer):Longint;stdcall;
implementation
{$R *.DFM}
function kk(Pointer):Longint;stdcall;
var
a:integer;
begin
Form1.label1.caption:='0';
for a:=1 to 100000 do begin
form1.label1.caption:=inttostr(strtoint(form1.label1.caption)+1);
// Application.ProcessMessages;
end;
end;
function kk1(Pointer):Longint;stdcall;
var
a:integer;
begin
Form1.label2.caption:='0';
for a:=1 to 100000 do begin
form1.label2.caption:=inttostr(strtoint(form1.label2.caption)+1);
//Application.ProcessMessages;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
hthread,a:thandle;
threadID,bword;
s:string;
begin
// hthread:=createthread(nil,18129,@kk, nil,0,threadid);
// a :=createthread(nil,18129,@kk1,nil,0,b);
CloseHandle(createthread(nil,64000,@kk, nil,0,threadid));
CloseHandle(createthread(nil,64000,@kk1,nil,0,b));
end;
end.