如何退出程序?

梅文海 2002-01-31 11:47:06
1.出于需要,在程序中先加载了数据模块,而不是主模块(如果是主模块便不存在这种情况了)。
2.然后分别加载了等待画面、登陆、和主模块。
程序平时在主模块退出时,没有任何问题,但在某些情况下会出错(程序退出,但用任务管理器察看仍然存在),我的资源释放全部是在主模块的OnCloseQuery中完成的,请教各位,有没有办法在资源释放不完全的情况下,将Application释放。

我得OnCloseQuery是这样的:
procedure TfrMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
try
if cfConfigFile<>nil then cfConfigFile.Free;

dispose(pSearchPer);
dmDataSource.dbSource.Connected:=False;
dmDataSource.CloseMe;
if frMateriel<>nil then frMateriel.CloseMe;
if frDefaultValue<>nil then frDefaultValue.CloseMe;
if frInfo<>nil then frInfo.CloseMe;
if frCurrencyList<>nil then frCurrencyList.CloseMe;
if frCurrencyInputAmend<>nil then frCurrencyInputAmend.CloseMe;
if frOtherReport<>nil then frOtherReport.CloseMe;
if frMyPreview<>nil then frMyPreview.CloseMe;
if frCurrencySearch<>nil then frCurrencySearch.CloseMe;
frLogin.Close;

except
on E:Exception do
myMessageBox(E.Message);
end;
end;
...全文
152 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ihihonline 2002-01-31
  • 打赏
  • 举报
回复
楼上的兄弟说得对,结束应用程序,不过打错了一个字,不好意思
application.teminate; //Terminate
~~~~~~~~~~~~~~~~~~~~~
Application.Terminate
hongyou 2002-01-31
  • 打赏
  • 举报
回复
uses Unit1;
退出时,加一句
Form1.close;
zjj_horse 2002-01-31
  • 打赏
  • 举报
回复
application.teminate;
梅文海 2002-01-31
  • 打赏
  • 举报
回复
这样行不行:
except
Application.Terminate;
on E:Exception do
myMessageBox(E.Message);
end;
china_lyz 2002-01-31
  • 打赏
  • 举报
回复
加在错误处理里面
梅文海 2002-01-31
  • 打赏
  • 举报
回复
如果是上面的程序,我应该加在哪?Except中?

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧