终止delphi应用程序的正确方法是什么? [英] Which is the proper way to terminate a delphi application?
问题描述
我想终止Delphi应用程序,而不执行任何其他代码行,我想知道哪个是正确的方法。此外,我想知道目前我在做什么有什么问题。
基本上,我的代码看起来像这样:
//释放所有对象(Obj1.Free等)
Application.Terminate;
暂停;
这是停止Delphi应用程序的正确方法还是应该以其他方式完成?
Application.Terminate()
打破 TApplication.Run()
和 TForm.ShowModal()
,允许主线程正常退出,执行必要的清理等。
结束执行应用程序。
调用
终止
以编程方式结束应用程序。通过调用终止
而不是释放应用程序对象,您可以允许应用程序以有序的方式关闭。
终止
调用Windows APIPostQuitMessage
函数来执行应用程序的有序关闭。终止
不立即。
终止
在WM_QUIT消息中自动调用当主窗体关闭时。
Halt()
手,是立即异常终止。基本上,把内存翻过来。仅在没有其他选项可用的极端情况下使用。
启动程序的异常终止 p>
停止执行程序的异常终止并返回到操作系统。
执行正常终止Delphi应用程序,在全局
应用程序
对象上调用终止
方法。如果应用程序不使用提供应用程序
对象的单位,请从主程序块调用Exit
程序。
I would like to terminate a Delphi application without executing any other code line and I'm wondering about which is the proper way to do this. Furthermore, I would like to know if there's something wrong in what I'm actually doing at the moment. Basically, my code looks like this:
//Freeing all objects (Obj1.Free, etc..)
Application.Terminate;
Halt;
Is this the right way to stop a Delphi application or should it be done in another way?
Application.Terminate()
breaks the message loops in TApplication.Run()
and TForm.ShowModal()
, allowing the main thread to exit normally, perform necessary cleanups, etc.
Vcl.Forms.TApplication.Terminate
Ends application execution.
Call
Terminate
to end the application programmatically. By callingTerminate
rather than freeing the application object, you allow the application to shut down in an orderly fashion.
Terminate
calls the Windows APIPostQuitMessage
function to perform an orderly shutdown of the application.Terminate
is not immediate.Terminate
is called automatically on a WM_QUIT message and when the main form closes.
Halt()
, on the other hand, is an immediate abnormal termination. Basically, ripping the process out of memory. Use it only in extreme situations where no other option is available.
Initiates the abnormal termination of a program.
Halt performs an abnormal termination of a program and returns to the operating system.
To perform a normal termination of a Delphi application, call the
Terminate
method on the globalApplication
object. If the application does not use a unit that provides anApplication
object, call theExit
procedure from the main Program block.
这篇关于终止delphi应用程序的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!