function Init(FormHandle: THandle): Boolean;stdcall;function Execute(TableName:string; ExcelFile:string; const   IsDelete:boolean=false):Boolean;stdcall;function Close(): Boolean;stdcall;以上三个函数是在dll里写的,我想在dll里开线程,然后再用上面这个三个函数调用线程。这样主程序再调用上面这三个函数。请问具体该怎么做呀?

解决方案 »

  1.   

    在dll中,定义一个全局的线程TMyThread myThead=nil;function Init(FormHandle: THandle): Boolean;stdcall;
    begin
      if (myThead = nil) then
      begin
        myThead := TMyThread.create(true);//创建时不立即执行
      end;
      
      ...
    end;function Execute(TableName:string; ExcelFile:string; const   IsDelete:boolean=false):Boolean;stdcall;
    begin
      myThead.resume();//运行线程
    end;function Close(): Boolean;stdcall;
    begin
      myThead.Terminate;end;
      

  2.   

    难道不需要重写线程类中的Create和Execute方法吗?