delphi7中,这段线程代码怎么总是出错,请大神指点

functionMyFun(p:Pointer):Integer;stdcall;varsSql,xlspath:string;i1,i2,i3:Integer;begi... function MyFun(p: Pointer): Integer; stdcall;
var
sSql, xlspath: string;
i1,i2,i3:Integer;
begin
if edt1.Text<>'' then
xlspath := trim(edt1.Text) //Excel路径
else
begin
ShowMessage('请选择相关文件');
Abort;
end;
try
lbl2.Visible:=true;
form1.Refresh;
i1:=DataModule8.qry_ljk.RecordCount;
DataModule8.qry_ljk.Close;
DataModule8.qry_ljk.SQL.Clear; // where 存货编码<>''''';
sSql :=
' INSERT INTO ljk (起动机编码,起动机名称,零件编码,零件名称,对应零件数量)'+
' SELECT'+
' 起动机编码,起动机名称,零件编码,零件名称,对应零件数量'+
' FROM [excel 8.0;database=' + xlspath +'].[sheet1$]';
DataModule8.qry_ljk.Parameters.Clear;
DataModule8.qry_ljk.ParamCheck := false;
DataModule8.qry_ljk.SQL.Text := sSql;
Application.ProcessMessages;
DataModule8.qry_ljk.Execsql;
with DataModule8.qry_ljk do
begin
Close;
SQL.Clear;
SQL.Add('select * from ljk');
Open;
i3:=DataModule8.qry_ljk.RecordCount;
end;
with DataModule8.qry_ljk do
begin
close;
sql.Clear;
Sql.Add('delete from ljk where id not in (select max(id) from ljk group by 起动机编码,零件编码)');
execsql;
//Application.ProcessMessages;
end;
with DataModule8.qry_ljk do
begin
close;
sql.Clear;
Sql.Add('Select * from ljk order by id');
Open;
end;
i2:=DataModule8.qry_ljk.RecordCount;
ShowMessage('重复记录'+inttostr(i3-i2)+'条 ,共添加 '+inttostr(i2-i1)+' 条新数据');
finally
lbl2.Visible:=False;
end;
procedure TForm1.btn1Click(Sender: TObject);
var
ID:dword;
thread:THandle;
begin
thread:=CreateThread(nil,0,@MyFun,nil,0,ID);
end;
end.
展开
 我来答
黎明808
2014-09-02 · TA获得超过2325个赞
知道小有建树答主
回答量:315
采纳率:0%
帮助的人:50.6万
展开全部
报的什么错啊?
追问

追答
:线程你还用这个干嘛:Application.ProcessMessages;去掉试试;
根据你的报错,我感觉问题不大;你试试重启;
国外有这样说法根据你的报错:
you may have run out of resources, which means a new DC cannot be
allocated. Usually this is a result of not freeing unused DCs or other
objects

you are attempting to draw to an device context that is not yet valid.
Such as in the create constructor of a component.

you are trying to draw on a canvas while your last draw-operation has
not finished yet. In this case you can use Canvas.Lock or Canvas.TryLock to fix it
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式