你如何干净地中止Delphi程序? [英] How do you cleanly abort a Delphi program?
问题描述
我有一个程序在关机时遇到麻烦,引发了我无法追溯到源代码的异常。它似乎是时间相关和非确定性的。这是在所有共享资源被释放之后发生的,而且由于关闭,内存泄漏不是一个问题,所以我想知道是否有任何方法可以让程序在释放共享资源之后立即和静默地终止,而不是继续关闭序列并提供异常消息框。
I've got a program that's having some trouble during shutdown, raising exceptions that I can't trace back to their source. It appears to be timing-related and non-deterministic. This is occurring after all shared resources have been released, and since it's shutdown, memory leaks are not an issue, so that makes me wonder if there's any way to just tell the program to terminate immediately and silently after releasing the shared resources, instead of continuing with the shutdown sequence and giving an exception message box.
有没有人知道如何做?
推荐答案
查看Delphi运行时库后的源代码,并在Microsoft文档中;我可以证实梅森和保罗 - 扬评论。
After looking at the Delphi Run Time Library source code, and at the Microsoft documentation; I can corroborate Mason and Paul-Jan comments.
关闭的层次结构如下
Application.Terminate()
performs some unidentified housekeeping of application
calls Halt()
Halt()
calls ExitProc if set
alerts the user in case of runtime error
get rid of PackageLoad call contexts that might be pending
finalize all units
clear all exception handlers
call ExitprocessProc if set
and finally, call ExitProcess() from 'kernel32.dll'
ExitProcess()
unloads all DLLs
uses TerminateProcess() to kill the process
这篇关于你如何干净地中止Delphi程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!