应该作完你自己应该做的....
在Application.Terminate;
在Application.Terminate;
解决方案 »
- 请教这段代码有什么问题,关于tfilestream
- 如何制作软件注册 与软件收费问题
- 我的 Delphi 2005 的 NewItem 中为什么没有 ECO WinForms Application ?
- 关于在delphi前台执行Transact-SQL的问题,高手请进!!!
- 小弟新近买了一个摄像头,接在电脑上,但我怎么样才能进行视象通话呢,要用什么软件啊?
- 高分请教!"软件工程"的哪本书值得看?
- 用socket控件时出错"List index out of bounds(0)"
- DBCtrlGrid中我如何根据表中的值决定某字段是否显示?可能有的行显示,有的不显示。
- 怎样截获sql server备份进度。
- 数据库中如何存储二进制流
- 在win98用ADOCONNECTION连接win2000上的sql server2000就连不上,这是为什么?
- 定义表之间的关系会不会减慢存取速度
//结束一个应用程序不用不同的方法
正如
Focus(老鱼) 所说
application.Terminate在一定条件下是可以的 ,有时它可能引起非法操作,或是就无法关闭应用程序;因为application.Terminate是要处理完所有的消息才结束应用程序,在意思上而言,不是正真的强得结束;但是如果你用application.halt的话,就会强行结束;
所以,你应该根据实际情况看;
但一般情况下是用application.Terminate;
Borland 真的这样说吗?
var
A,B: TComponent;
begin
A.Create(nil);
B.Create(A);
A.Free;
end;
这时候不需要调用B.Free我的理解是这样的,但因为不知道VCL底层的原理,所以总是非常担心这样会造成内存泄漏。哪位高手能够详细讲解一下?
but .terminate can close a app safely
donot use .halt except your app no response!
A,B: TComponent;
begin
A.Create(nil);
B.Create(A);
A.Free;
end;
这时候不需要调用B.Free因为这时A是B的Owner,当A被Free时,会将所有它管理的对象实例Free,所以,如果再写B.Free反而会错,因为B已经释放了。
TComponent的子类的构造函数Create(AOwner: TComponent)
当AOwner被释放时他的子对象也就同时被释放了,这个过程Delphi会自动调用!
所以不必但心会出现问题!相信我们的Delphi
DescriptionTApplication encapsulates a Windows application. The methods and properties introduced in TApplication reflect the fundamentals established in the Windows operating system to create, run, sustain, and destroy an application. TApplication thereby simplifies the interface between the developer and the Windows environment. For this purpose TApplication encapsulates behavior for:Windows message processing.
Context-sensitive online help.
Menu accelerator and key processing.
Exception handling.
Managing the fundamental parts defined by the Windows operating system for an application, such as MainWindow, WindowClass, and so on
halt是强行关闭应用程序且返回到操作系统,他是一个过程,DELPHI定义的。
第二,halt方法太霸道,不会Free掉任何form的,不到万不得以不要用吧!
terminate可以理解为通过pcb中的记录释放application登记的资源,但是我想pcb中没有登记的资源是不会自动释放的,比如打开的驱动程序句柄。thread会释放的,因为thread是运行在application登记在pcb中的地址范围内。
halt估计就是简单的从系统队列中摘除掉pcb把。。
-------
以上都是个人猜想。
我用TERMINATE结束程序后,
然后DELE程序,报源程序还在使用的错!T
能否XXXXXX,问老Bill去!!!
Halt是直接结束应用程序,两者是有些不同的。