L
lizheng
Unregistered / Unconfirmed
GUEST, unregistred user!
function ThreadFunc(P: Pointer): LongInt;
stdcall;
var
i: Integer;
DC: HDC;
S: string;
begin
DC := GetDC(Form1.Handle);
SetBkColor(DC, GetSysColor(color_btnface));
for i := 0 to 100000do
begin
S := IntToStr(i);
TextOut(DC, 10, 10, PChar(S), Length(S));
end;
ReleaseDC(Form1.Handle, DC);
end;
procedure TForm1.FindFile1Click(Sender: TObject);
label show;
var
hThread:THandle;
ThreadIDWord;
pathointer;
begin
show:
form3.ShowModal;
if form3.ModalResult=mrok then
if (form3.Edit1.Text='') or (form3.Edit2.Text='') then
begin
messagebeep(MB_ICONEXCLAMATION);
messagedlg('something necessary you did not fill',mterror,[mbok],0);
goto show;
end
else
begin
datamodule2.table2.Append;
datamodule2.table2.FieldByName('光盘编号').asinteger:=strtoint(form3.edit2.text);
datamodule2.table2.FieldByName('光盘名称').asstring:=form3.edit1.text;
path:=Pointer(new(Ppath));
Ppath(path)^.path:=form3.DriveComboBox1.Drive+':/';
Hthread:=CreateThread(nil,0,@ThreadFunc,path,0,ThreadID);
~~~~~~
出错:Undeclared Identifier?
if hthread=0 then
messageBox(Handle,'no Thread',nil,MB_OK);
//form1.FindFile(form3.DriveComboBox1.Drive+':/');
end;
end;
可下面程序中的调用是对的:
procedure TForm1.bUseThreadClick(Sender: TObject);
var
hThread: THandle;
ThreadID: DWord;
begin
hthread := CreateThread(nil, //Security attribute
0, //Initial Stack
@ThreadFunc, //Starting address of thread
nil, // argument of thread
0, // Create flags
ThreadID);
// thread ID
if hthread = 0 then
MessageBox(Handle, 'No Thread', nil, MB_OK);
end;
调用的是同样的函数,一个编译通过,一个不行(虽然是在不同的程序中)。想不通?
stdcall;
var
i: Integer;
DC: HDC;
S: string;
begin
DC := GetDC(Form1.Handle);
SetBkColor(DC, GetSysColor(color_btnface));
for i := 0 to 100000do
begin
S := IntToStr(i);
TextOut(DC, 10, 10, PChar(S), Length(S));
end;
ReleaseDC(Form1.Handle, DC);
end;
procedure TForm1.FindFile1Click(Sender: TObject);
label show;
var
hThread:THandle;
ThreadIDWord;
pathointer;
begin
show:
form3.ShowModal;
if form3.ModalResult=mrok then
if (form3.Edit1.Text='') or (form3.Edit2.Text='') then
begin
messagebeep(MB_ICONEXCLAMATION);
messagedlg('something necessary you did not fill',mterror,[mbok],0);
goto show;
end
else
begin
datamodule2.table2.Append;
datamodule2.table2.FieldByName('光盘编号').asinteger:=strtoint(form3.edit2.text);
datamodule2.table2.FieldByName('光盘名称').asstring:=form3.edit1.text;
path:=Pointer(new(Ppath));
Ppath(path)^.path:=form3.DriveComboBox1.Drive+':/';
Hthread:=CreateThread(nil,0,@ThreadFunc,path,0,ThreadID);
~~~~~~
出错:Undeclared Identifier?
if hthread=0 then
messageBox(Handle,'no Thread',nil,MB_OK);
//form1.FindFile(form3.DriveComboBox1.Drive+':/');
end;
end;
可下面程序中的调用是对的:
procedure TForm1.bUseThreadClick(Sender: TObject);
var
hThread: THandle;
ThreadID: DWord;
begin
hthread := CreateThread(nil, //Security attribute
0, //Initial Stack
@ThreadFunc, //Starting address of thread
nil, // argument of thread
0, // Create flags
ThreadID);
// thread ID
if hthread = 0 then
MessageBox(Handle, 'No Thread', nil, MB_OK);
end;
调用的是同样的函数,一个编译通过,一个不行(虽然是在不同的程序中)。想不通?