将 一个在FORM窗口中的 uniquery 传入到DLL中后执行
命令没有问题,但是一退出主程序就出错,请问是为什么 
 with UniQuery do
    begin
      Close;
      SQL.Text := SelectText;
      Open;
    end;
执行上面这样的命令后退出主程序就出错,我是在一个主窗口中弹出另一个Form窗体,然后一个按钮执行procedure DLLUnloadProc(Reason: Integer); register;
begin
  if (Reason = DLL_PROCESS_DETACH) or (Reason = DLL_THREAD_DETACH) then
    Application := DLLApp;
end;procedure ShowSelectWindow(APP: TApplication; H: THandle; Frm: TForm; DBGridEh1: TDBGridEh; AUniQuery: TUniQuery; SelectSqltext: WideString; N: Integer);
begin
  Application.Handle := H;
  DLLAPP := Application;
  DLLProc := @DLLUnloadProc;
  Application := TApplication(app);
  F_SelectWin := TF_SelectWin.Create(frm);
  try
    with F_SelectWin do
    begin
      Hide;
      ParentSelectSqltext := SelectSqltext;
      DBGridEhX := DBGridEh1;
      UniQuery := AUniQuery;
      BorderStyle := bsDialog;
      Position := poScreenCenter;
      Showmodal;
    end;
  finally
    FreeAndNil(F_SelectWin);
  end;end;