L
La Mer
Unregistered / Unconfirmed
GUEST, unregistred user!
uses ShellAPI 。。。;
function thd_StartExporting(pointer):Longint;overload;
var dc : HDC;
i : integer;
DestFileName : string;
begin
Result:=0;
dc:=GetDc(frm_Main.handle);
Application.Initialize;
OleInitialize(nil);
with frm_Maindo
begin
xls_App.Workbooks.Open('。。。',
EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,0);
xls_Book.ConnectTo(xls_App.Workbooks[1]);
xls_Sheet.ConnectTo(xls_Book.Sheets[1] as _WorkSheet);
try
。。。
finally
xls_Book.Close;
xls_Sheet.Disconnect;
xls_Book.Disconnect;
xls_App.Disconnect;
xls_App.Quit;
end;
// try
end;
// with frm_Maindo
ReleaseDc(frm_Main.handle,dc);
end;
procedure Tfrm_Main.btn_StartClick(Sender: TObject);
begin
HD:=CreateThread(nil,0,@thd_StartExporting,nil,0,ThID);
end;
只要一运行这个线程就出错:Access violation at address 0049B7C2 in module 'EXCEL_Exporter.exe' of address 0000001D.
可爱的是,“确定”之后,程序还一样能照常运行。
请问如何想办法有效去掉这个错误(提示)?谢谢!
② 还有个小问题顺便请教一下:怎么用API函数判断这种纯API现成到底有没有结束?
function thd_StartExporting(pointer):Longint;overload;
var dc : HDC;
i : integer;
DestFileName : string;
begin
Result:=0;
dc:=GetDc(frm_Main.handle);
Application.Initialize;
OleInitialize(nil);
with frm_Maindo
begin
xls_App.Workbooks.Open('。。。',
EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,0);
xls_Book.ConnectTo(xls_App.Workbooks[1]);
xls_Sheet.ConnectTo(xls_Book.Sheets[1] as _WorkSheet);
try
。。。
finally
xls_Book.Close;
xls_Sheet.Disconnect;
xls_Book.Disconnect;
xls_App.Disconnect;
xls_App.Quit;
end;
// try
end;
// with frm_Maindo
ReleaseDc(frm_Main.handle,dc);
end;
procedure Tfrm_Main.btn_StartClick(Sender: TObject);
begin
HD:=CreateThread(nil,0,@thd_StartExporting,nil,0,ThID);
end;
只要一运行这个线程就出错:Access violation at address 0049B7C2 in module 'EXCEL_Exporter.exe' of address 0000001D.
可爱的是,“确定”之后,程序还一样能照常运行。
请问如何想办法有效去掉这个错误(提示)?谢谢!
② 还有个小问题顺便请教一下:怎么用API函数判断这种纯API现成到底有没有结束?